s3-winbind: Don't set the gecos field to NULL.
[obnox/samba/samba-obnox.git] / source3 / winbindd / nss_info_template.c
1 /* 
2    Unix SMB/CIFS implementation.
3    idMap nss template plugin
4
5    Copyright (C) Gerald Carter             2006
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 3 of the License, or (at your option) any later version.
11
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Library General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "includes.h"
22 #include "ads.h"
23 #include "nss_info.h"
24
25 /************************************************************************
26  ***********************************************************************/
27
28 static NTSTATUS nss_template_init( struct nss_domain_entry *e )
29 {
30         return NT_STATUS_OK;
31 }
32
33 /************************************************************************
34  ***********************************************************************/
35
36 static NTSTATUS nss_template_get_info( struct nss_domain_entry *e,
37                                        const struct dom_sid *sid,
38                                        TALLOC_CTX *ctx,
39                                        const char **homedir,
40                                        const char **shell,
41                                        const char **gecos,
42                                        gid_t *gid )
43 {     
44         if ( !homedir || !shell || !gecos )
45                 return NT_STATUS_INVALID_PARAMETER;
46
47         /* protect against home directories using whitespace in the
48           username */
49         *homedir = talloc_strdup( ctx, lp_template_homedir() );
50         *shell   = talloc_strdup( ctx, lp_template_shell() );
51
52         if ( !*homedir || !*shell ) {
53                 return NT_STATUS_NO_MEMORY;
54         }
55
56         return NT_STATUS_OK;
57 }
58
59 /**********************************************************************
60  *********************************************************************/
61
62 static NTSTATUS nss_template_map_to_alias( TALLOC_CTX *mem_ctx,
63                                            struct nss_domain_entry *e,
64                                            const char *name,
65                                            char **alias )
66 {
67         return NT_STATUS_NOT_IMPLEMENTED;
68 }
69
70 /**********************************************************************
71  *********************************************************************/
72
73 static NTSTATUS nss_template_map_from_alias( TALLOC_CTX *mem_ctx,
74                                              struct nss_domain_entry *e,
75                                              const char *alias,
76                                              char **name )
77 {
78         return NT_STATUS_NOT_IMPLEMENTED;
79 }
80
81 /************************************************************************
82  ***********************************************************************/
83
84 static NTSTATUS nss_template_close( void )
85 {
86         return NT_STATUS_OK;
87 }
88
89
90 /************************************************************************
91  ***********************************************************************/
92
93 static struct nss_info_methods nss_template_methods = {
94         .init           = nss_template_init,
95         .get_nss_info   = nss_template_get_info,
96         .map_to_alias   = nss_template_map_to_alias,
97         .map_from_alias = nss_template_map_from_alias,
98         .close_fn       = nss_template_close
99 };
100
101 NTSTATUS nss_info_template_init( void )
102 {
103         return smb_register_idmap_nss(SMB_NSS_INFO_INTERFACE_VERSION, 
104                                       "template", 
105                                       &nss_template_methods);   
106 }
107