関数 | |
static int | net_idmap_dump_one_entry (TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA data, void *unused) |
static int | net_idmap_dump (int argc, const char **argv) |
static int | net_idmap_restore (int argc, const char **argv) |
static int | net_idmap_delete (int argc, const char **argv) |
static int | net_idmap_set (int argc, const char **argv) |
BOOL | idmap_store_secret (const char *backend, bool alloc, const char *domain, const char *identity, const char *secret) |
static int | net_idmap_secret (int argc, const char **argv) |
int | net_help_idmap (int argc, const char **argv) |
int | net_idmap (int argc, const char **argv) |
static int net_idmap_dump_one_entry | ( | TDB_CONTEXT * | tdb, | |
TDB_DATA | key, | |||
TDB_DATA | data, | |||
void * | unused | |||
) | [static] |
net_idmap.c の 33 行で定義されています。
参照先 TDB_DATA::dptr・printf().
参照元 net_idmap_dump().
00037 { 00038 if (strcmp(key.dptr, "USER HWM") == 0) { 00039 printf("USER HWM %d\n", IVAL(data.dptr,0)); 00040 return 0; 00041 } 00042 00043 if (strcmp(key.dptr, "GROUP HWM") == 0) { 00044 printf("GROUP HWM %d\n", IVAL(data.dptr,0)); 00045 return 0; 00046 } 00047 00048 if (strncmp(key.dptr, "S-", 2) != 0) 00049 return 0; 00050 00051 printf("%s %s\n", data.dptr, key.dptr); 00052 return 0; 00053 }
static int net_idmap_dump | ( | int | argc, | |
const char ** | argv | |||
) | [static] |
net_idmap.c の 58 行で定義されています。
参照先 d_fprintf()・net_help_idmap()・net_idmap_dump_one_entry()・tdb_close()・tdb_open_log()・tdb_traverse().
参照元 net_idmap().
00059 { 00060 TDB_CONTEXT *idmap_tdb; 00061 00062 if ( argc != 1 ) 00063 return net_help_idmap( argc, argv ); 00064 00065 idmap_tdb = tdb_open_log(argv[0], 0, TDB_DEFAULT, O_RDONLY, 0); 00066 00067 if (idmap_tdb == NULL) { 00068 d_fprintf(stderr, "Could not open idmap: %s\n", argv[0]); 00069 return -1; 00070 } 00071 00072 tdb_traverse(idmap_tdb, net_idmap_dump_one_entry, NULL); 00073 00074 tdb_close(idmap_tdb); 00075 00076 return 0; 00077 }
static int net_idmap_restore | ( | int | argc, | |
const char ** | argv | |||
) | [static] |
net_idmap.c の 83 行で定義されています。
参照先 ctx・d_fprintf()・unixid::id・ID_TYPE_GID・ID_TYPE_UID・len・line・id_map::sid・sid_string_static()・string_to_sid()・talloc_free()・unixid::type・winbind_ping()・winbind_set_gid_hwm()・winbind_set_mapping()・winbind_set_uid_hwm()・id_map::xid.
参照元 net_idmap().
00084 { 00085 TALLOC_CTX *ctx; 00086 FILE *input; 00087 00088 if (! winbind_ping()) { 00089 d_fprintf(stderr, "To use net idmap Winbindd must be running.\n"); 00090 return -1; 00091 } 00092 00093 ctx = talloc_new(NULL); 00094 ALLOC_CHECK(ctx); 00095 00096 if (argc == 1) { 00097 input = fopen(argv[0], "r"); 00098 } else { 00099 input = stdin; 00100 } 00101 00102 while (!feof(input)) { 00103 char line[128], sid_string[128]; 00104 int len; 00105 DOM_SID sid; 00106 struct id_map map; 00107 unsigned long idval; 00108 00109 if (fgets(line, 127, input) == NULL) 00110 break; 00111 00112 len = strlen(line); 00113 00114 if ( (len > 0) && (line[len-1] == '\n') ) 00115 line[len-1] = '\0'; 00116 00117 if (sscanf(line, "GID %lu %128s", &idval, sid_string) == 2) { 00118 map.xid.type = ID_TYPE_GID; 00119 map.xid.id = idval; 00120 } else if (sscanf(line, "UID %lu %128s", &idval, sid_string) == 2) { 00121 map.xid.type = ID_TYPE_UID; 00122 map.xid.id = idval; 00123 } else if (sscanf(line, "USER HWM %lu", &idval) == 1) { 00124 /* set uid hwm */ 00125 if (! winbind_set_uid_hwm(idval)) { 00126 d_fprintf(stderr, "Could not set USER HWM\n"); 00127 } 00128 continue; 00129 } else if (sscanf(line, "GROUP HWM %lu", &idval) == 1) { 00130 /* set gid hwm */ 00131 if (! winbind_set_gid_hwm(idval)) { 00132 d_fprintf(stderr, "Could not set GROUP HWM\n"); 00133 } 00134 continue; 00135 } else { 00136 d_fprintf(stderr, "ignoring invalid line [%s]\n", line); 00137 continue; 00138 } 00139 00140 if (!string_to_sid(&sid, sid_string)) { 00141 d_fprintf(stderr, "ignoring invalid sid [%s]\n", sid_string); 00142 continue; 00143 } 00144 map.sid = &sid; 00145 00146 if (!winbind_set_mapping(&map)) { 00147 d_fprintf(stderr, "Could not set mapping of %s %lu to sid %s\n", 00148 (map.xid.type == ID_TYPE_GID) ? "GID" : "UID", 00149 (unsigned long)map.xid.id, sid_string_static(map.sid)); 00150 continue; 00151 } 00152 00153 } 00154 00155 if (input != stdin) { 00156 fclose(input); 00157 } 00158 00159 talloc_free(ctx); 00160 return 0; 00161 }
static int net_idmap_delete | ( | int | argc, | |
const char ** | argv | |||
) | [static] |
net_idmap.c の 166 行で定義されています。
参照先 d_printf().
参照元 net_idmap().
00167 { 00168 d_printf("Not Implemented yet\n"); 00169 return -1; 00170 }
static int net_idmap_set | ( | int | argc, | |
const char ** | argv | |||
) | [static] |
net_idmap.c の 172 行で定義されています。
参照先 d_printf().
参照元 net_idmap().
00173 { 00174 d_printf("Not Implemented yet\n"); 00175 return -1; 00176 }
BOOL idmap_store_secret | ( | const char * | backend, | |
bool | alloc, | |||
const char * | domain, | |||
const char * | identity, | |||
const char * | secret | |||
) |
net_idmap.c の 177 行で定義されています。
参照先 asprintf()・secrets_store_generic()・strupper_m().
参照元 net_idmap_secret().
00180 { 00181 char *tmp; 00182 int r; 00183 BOOL ret; 00184 00185 if (alloc) { 00186 r = asprintf(&tmp, "IDMAP_ALLOC_%s", backend); 00187 } else { 00188 r = asprintf(&tmp, "IDMAP_%s_%s", backend, domain); 00189 } 00190 00191 if (r < 0) return false; 00192 00193 strupper_m(tmp); /* make sure the key is case insensitive */ 00194 ret = secrets_store_generic(tmp, identity, secret); 00195 00196 free(tmp); 00197 return ret; 00198 }
static int net_idmap_secret | ( | int | argc, | |
const char ** | argv | |||
) | [static] |
net_idmap.c の 201 行で定義されています。
参照先 ctx・d_fprintf()・d_printf()・idmap_store_secret()・lp_parm_const_string()・net_help_idmap()・strequal()・talloc_asprintf()・talloc_free()・talloc_strdup().
参照元 net_idmap().
00202 { 00203 TALLOC_CTX *ctx; 00204 const char *secret; 00205 const char *dn; 00206 char *domain; 00207 char *backend; 00208 char *opt = NULL; 00209 BOOL ret; 00210 00211 if (argc != 2) { 00212 return net_help_idmap(argc, argv); 00213 } 00214 00215 secret = argv[1]; 00216 00217 ctx = talloc_new(NULL); 00218 ALLOC_CHECK(ctx); 00219 00220 if (strcmp(argv[0], "alloc") == 0) { 00221 domain = NULL; 00222 backend = lp_idmap_alloc_backend(); 00223 } else { 00224 domain = talloc_strdup(ctx, argv[0]); 00225 ALLOC_CHECK(domain); 00226 00227 opt = talloc_asprintf(ctx, "idmap config %s", domain); 00228 ALLOC_CHECK(opt); 00229 00230 backend = talloc_strdup(ctx, lp_parm_const_string(-1, opt, "backend", "tdb")); 00231 ALLOC_CHECK(backend); 00232 } 00233 00234 if ( ( ! backend) || ( ! strequal(backend, "ldap"))) { 00235 d_fprintf(stderr, "The only currently supported backend is LDAP\n"); 00236 talloc_free(ctx); 00237 return -1; 00238 } 00239 00240 if (domain) { 00241 00242 dn = lp_parm_const_string(-1, opt, "ldap_user_dn", NULL); 00243 if ( ! dn) { 00244 d_fprintf(stderr, "Missing ldap_user_dn option for domain %s\n", domain); 00245 talloc_free(ctx); 00246 return -1; 00247 } 00248 00249 ret = idmap_store_secret("ldap", false, domain, dn, secret); 00250 } else { 00251 dn = lp_parm_const_string(-1, "idmap alloc config", "ldap_user_dn", NULL); 00252 if ( ! dn) { 00253 d_fprintf(stderr, "Missing ldap_user_dn option for alloc backend\n"); 00254 talloc_free(ctx); 00255 return -1; 00256 } 00257 00258 ret = idmap_store_secret("ldap", true, NULL, dn, secret); 00259 } 00260 00261 if ( ! ret) { 00262 d_fprintf(stderr, "Failed to store secret\n"); 00263 talloc_free(ctx); 00264 return -1; 00265 } 00266 00267 d_printf("Secret stored\n"); 00268 return 0; 00269 }
int net_help_idmap | ( | int | argc, | |
const char ** | argv | |||
) |
net_idmap.c の 271 行で定義されています。
参照先 d_printf().
参照元 net_idmap()・net_idmap_dump()・net_idmap_secret().
00272 { 00273 d_printf("net idmap dump <inputfile>\n"\ 00274 " Dump current id mapping\n"); 00275 00276 d_printf("net idmap restore\n"\ 00277 " Restore entries from stdin\n"); 00278 00279 /* Deliberately *not* document net idmap delete */ 00280 00281 d_printf("net idmap secret <DOMAIN>|alloc <secret>\n"\ 00282 " Set the secret for the specified DOMAIN (or the alloc module)\n"); 00283 00284 return -1; 00285 }
int net_idmap | ( | int | argc, | |
const char ** | argv | |||
) |
net_idmap.c の 290 行で定義されています。
参照先 net_help_idmap()・net_idmap_delete()・net_idmap_dump()・net_idmap_restore()・net_idmap_secret()・net_idmap_set()・net_run_function().
00291 { 00292 struct functable func[] = { 00293 {"dump", net_idmap_dump}, 00294 {"restore", net_idmap_restore}, 00295 {"setmap", net_idmap_set }, 00296 {"delete", net_idmap_delete}, 00297 {"secret", net_idmap_secret}, 00298 {"help", net_help_idmap}, 00299 {NULL, NULL} 00300 }; 00301 00302 return net_run_function(argc, argv, func, net_help_idmap); 00303 }