r18754: Get rid of some more invalid time sets
[Samba/bb.git] / source3 / sam / nss_info.c
blob6d01916754e142ad5a7877836482a0aa482cecb7
1 /*
2 Unix SMB/CIFS implementation.
3 nss info helpers
4 Copyright (C) Guenther Deschner 2006
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/
20 #include "includes.h"
22 #undef DBGC_CLASS
23 #define DBGC_CLASS DBGC_IDMAP
25 static enum wb_posix_mapping wb_posix_map_type(const char *map_str)
27 if (strequal(map_str, "template"))
28 return WB_POSIX_MAP_TEMPLATE;
29 else if (strequal(map_str, "sfu"))
30 return WB_POSIX_MAP_SFU;
31 else if (strequal(map_str, "rfc2307"))
32 return WB_POSIX_MAP_RFC2307;
33 else if (strequal(map_str, "unixinfo"))
34 return WB_POSIX_MAP_UNIXINFO;
36 return WB_POSIX_MAP_UNKNOWN;
39 /* winbind nss info = rfc2307 SO36:sfu FHAIN:rfc2307 PANKOW:template
41 * syntax is:
42 * 1st param: default setting
43 * following ":" separated list elements:
44 * DOMAIN:setting
45 * setting can be one of "sfu", "rfc2307", "template", "unixinfo"
48 enum wb_posix_mapping get_nss_info(const char *domain_name)
50 const char **list = lp_winbind_nss_info();
51 enum wb_posix_mapping map_templ = WB_POSIX_MAP_TEMPLATE;
52 int i;
54 DEBUG(11,("get_nss_info for %s\n", domain_name));
56 if (!lp_winbind_nss_info() || !*lp_winbind_nss_info()) {
57 return WB_POSIX_MAP_TEMPLATE;
60 if ((map_templ = wb_posix_map_type(list[0])) == WB_POSIX_MAP_UNKNOWN) {
61 DEBUG(0,("get_nss_info: invalid setting: %s\n", list[0]));
62 return WB_POSIX_MAP_TEMPLATE;
65 DEBUG(11,("get_nss_info: using \"%s\" by default\n", list[0]));
67 for (i=0; list[i]; i++) {
69 const char *p = list[i];
70 fstring tok;
72 if (!next_token(&p, tok, ":", sizeof(tok))) {
73 DEBUG(0,("get_nss_info: no \":\" delimitier found\n"));
74 continue;
77 if (strequal(tok, domain_name)) {
79 enum wb_posix_mapping type;
81 if ((type = wb_posix_map_type(p)) == WB_POSIX_MAP_UNKNOWN) {
82 DEBUG(0,("get_nss_info: invalid setting: %s\n", p));
83 /* return WB_POSIX_MAP_TEMPLATE; */
84 continue;
87 DEBUG(11,("get_nss_info: using \"%s\" for domain: %s\n", p, tok));
89 return type;
93 return map_templ;
96 const char *wb_posix_map_str(enum wb_posix_mapping mtype)
98 switch (mtype) {
99 case WB_POSIX_MAP_TEMPLATE:
100 return "template";
101 case WB_POSIX_MAP_SFU:
102 return "sfu";
103 case WB_POSIX_MAP_RFC2307:
104 return "rfc2307";
105 case WB_POSIX_MAP_UNIXINFO:
106 return "unixinfo";
107 default:
108 break;
110 return NULL;