void simulator (int argc, char **argv) { xlog_stderr (1); xlog_syslog (0); xlog_open ("statd simulator"); if (argc == 2) if (!strcasecmp (*argv, "crash")) simulate_crash (*(&argv[1])); if (argc == 3) { if (!strcasecmp (*argv, "stat")) simulate_stat (*(&argv[1]), *(&argv[2])); } if (argc == 4) { if (!strcasecmp (*argv, "unmon_all")) simulate_unmon_all (*(&argv[1]), *(&argv[2]), *(&argv[3])); } if (argc == 5) { if (!strcasecmp (*argv, "unmon")) simulate_unmon (*(&argv[1]), *(&argv[2]), *(&argv[3]), *(&argv[4])); } if (argc == 6) { if (!strcasecmp (*argv, "mon")) simulate_mon (*(&argv[1]), *(&argv[2]), *(&argv[3]), *(&argv[4]), *(&argv[5])); } xlog_err ("WTF? Give me something I can use!"); }
void initerr(char *progname, int set_verbosity, int set_fg) { verbosity = set_verbosity; fg = set_fg; if (!fg) xlog_open(progname); }
/** * Program entry point * * @param argc count of command line arguments * @param argv array of NUL-terminated C strings containing command line arguments * @return program exit status */ int main(int argc, char **argv) { char *progname, *pathname, *buf = NULL; FedFsStatus retval; int fd; (void)setlocale(LC_ALL, ""); /* For the libraries */ if ((progname = strrchr(argv[0], '/')) != NULL) progname++; else progname = argv[0]; xlog_stderr(1); xlog_syslog(0); xlog_open(progname); if (argc != 2) { fprintf(stderr, "Usage: %s <pathname>\n", progname); return EXIT_FAILURE; } pathname = argv[1]; retval = junction_open_path(pathname, &fd); switch (retval) { case FEDFS_OK: break; case FEDFS_ERR_PERM: fprintf(stderr, "Failed to open junction %s: not running as root\n", pathname); return EXIT_FAILURE; default: fprintf(stderr, "Failed to open junction %s: %s\n", pathname, nsdb_display_fedfsstatus(retval)); return EXIT_FAILURE; } retval = junction_read_xattr(fd, pathname, JUNCTION_XATTR_NAME_NFS, &buf); switch (retval) { case FEDFS_OK: break; case FEDFS_ERR_ACCESS: fprintf(stderr, "Object %s is not a junction\n", pathname); return EXIT_FAILURE; default: fprintf(stderr, "Failed to read junction %s: %s\n", pathname, nsdb_display_fedfsstatus(retval)); return EXIT_FAILURE; } printf("%s\n", buf); free(buf); (void)close(fd); return retval; }
int main(int argc, char **argv) { xlog_syslog(0); xlog_stderr(1); xlog_open(argv[0]); nsm_load_monitor_list(dump_host); return 0; }
/** * Program entry point * * @param argc count of command line arguments * @param argv array of NUL-terminated C strings containing command line arguments * @return program exit status */ int main(int argc, char **argv) { char *progname, *binddn, *nsdbname, *nce, *parent; unsigned short nsdbport; unsigned int ldap_err; FedFsStatus retval; nsdb_t host; int arg; (void)setlocale(LC_ALL, ""); (void)umask(S_IRWXO); /* Set the basename */ if ((progname = strrchr(argv[0], '/')) != NULL) progname++; else progname = argv[0]; /* For the libraries */ xlog_stderr(1); xlog_syslog(0); xlog_open(progname); nsdb_env(&nsdbname, &nsdbport, &binddn, NULL); while ((arg = getopt_long(argc, argv, nsdb_simple_nce_opts, nsdb_simple_nce_longopts, NULL)) != -1) { switch (arg) { case 'd': xlog_config(D_ALL, 1); nsdb_enable_ldap_debugging(); break; case 'D': binddn = optarg; break; case 'l': nsdbname = optarg; break; case 'r': if (!nsdb_parse_port_string(optarg, &nsdbport)) { fprintf(stderr, "Bad port number: %s\n", optarg); nsdb_simple_nce_usage(progname); } break; default: fprintf(stderr, "Invalid command line " "argument: %c\n", (char)arg); case '?': nsdb_simple_nce_usage(progname); } } if (argc == optind + 1) { parent = argv[optind]; } else if (argc > optind + 1) { fprintf(stderr, "Unrecognized positional parameters\n"); nsdb_simple_nce_usage(progname); } else { fprintf(stderr, "No parent DN specified\n"); nsdb_simple_nce_usage(progname); } if (nsdbname == NULL) { fprintf(stderr, "Missing required command line argument\n"); nsdb_simple_nce_usage(progname); } retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host); switch (retval) { case FEDFS_OK: break; case FEDFS_ERR_NSDB_PARAMS: fprintf(stderr, "No connection parameters for NSDB %s:%u\n", nsdbname, nsdbport); goto out; default: fprintf(stderr, "Failed to look up NSDB %s:%u: %s\n", nsdbname, nsdbport, nsdb_display_fedfsstatus(retval)); goto out; } if (binddn == NULL) binddn = (char *)nsdb_default_binddn(host); retval = nsdb_open_nsdb(host, binddn, NULL, &ldap_err); switch (retval) { case FEDFS_OK: break; case FEDFS_ERR_INVAL: fprintf(stderr, "Missing or invalid password\n"); goto out_free; case FEDFS_ERR_NSDB_CONN: fprintf(stderr, "Failed to connect to NSDB %s:%u\n", nsdbname, nsdbport); goto out_free; case FEDFS_ERR_NSDB_AUTH: fprintf(stderr, "Failed to establish secure connection " "to NSDB %s:%u\n", nsdbname, nsdbport); goto out_free; case FEDFS_ERR_NSDB_LDAP_VAL: switch (ldap_err) { case LDAP_INVALID_CREDENTIALS: fprintf(stderr, "Incorrect password for DN %s\n", binddn); break; default: fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n", nsdbname, nsdbport, ldap_err2string(ldap_err)); } goto out_free; default: fprintf(stderr, "Failed to open NSDB %s:%u: %s\n", nsdbname, nsdbport, nsdb_display_fedfsstatus(retval)); goto out_free; } retval = nsdb_create_simple_nce_s(host, parent, &nce, &ldap_err); switch (retval) { case FEDFS_OK: break; case FEDFS_ERR_NSDB_LDAP_VAL: fprintf(stderr, "Failed to create NCE: %s\n", ldap_err2string(ldap_err)); goto out_close; default: fprintf(stderr, "Failed to create NCE: %s\n", nsdb_display_fedfsstatus(retval)); goto out_close; } retval = nsdb_update_nci_s(host, nce, &ldap_err); switch (retval) { case FEDFS_OK: printf("Successfully created NCE %s\n", nce); break; case FEDFS_ERR_NSDB_NONCE: /* XXX: should not occur */ fprintf(stderr, "Entry %s is not a naming context " "for this NSDB\n", nce); break; case FEDFS_ERR_NSDB_LDAP_VAL: switch (ldap_err) { case LDAP_REFERRAL: fprintf(stderr, "Encountered LDAP referral on %s:%u\n", nsdbname, nsdbport); break; case LDAP_CONFIDENTIALITY_REQUIRED: fprintf(stderr, "TLS security required for %s:%u\n", nsdbname, nsdbport); break; default: fprintf(stderr, "Failed to update NCI: %s\n", ldap_err2string(ldap_err)); } break; default: fprintf(stderr, "Failed to update NCI: %s\n", nsdb_display_fedfsstatus(retval)); } free(nce); out_close: nsdb_close_nsdb(host); out_free: nsdb_free_nsdb(host); out: exit((int)retval); }
int main(int argc, char **argv) { char *export_file = _PATH_EXPORTS; char *state_dir = NFS_STATEDIR; int foreground = 0; int port = 0; int descriptors = 0; int c; struct sigaction sa; struct rlimit rlim; /* Parse the command line options and arguments. */ opterr = 0; while ((c = getopt_long(argc, argv, "o:nFd:f:p:P:hH:N:V:vrs:t:g", longopts, NULL)) != EOF) switch (c) { case 'g': manage_gids = 1; break; case 'o': descriptors = atoi(optarg); if (descriptors <= 0) { fprintf(stderr, "%s: bad descriptors: %s\n", argv [0], optarg); usage(argv [0], 1); } break; case 'F': foreground = 1; break; case 'd': xlog_sconfig(optarg, 1); break; case 'f': export_file = optarg; break; case 'H': /* PRC: specify a high-availability callout program */ ha_callout_prog = optarg; break; case 'h': usage(argv [0], 0); break; case 'P': /* XXX for nfs-server compatibility */ case 'p': port = atoi(optarg); if (port <= 0 || port > 65535) { fprintf(stderr, "%s: bad port number: %s\n", argv [0], optarg); usage(argv [0], 1); } break; case 'N': nfs_version &= ~(1 << (atoi (optarg) - 1)); break; case 'n': _rpcfdtype = SOCK_DGRAM; break; case 'r': reverse_resolve = 1; break; case 's': if ((state_dir = xstrdup(optarg)) == NULL) { fprintf(stderr, "%s: xstrdup(%s) failed!\n", argv[0], optarg); exit(1); } break; case 't': num_threads = atoi (optarg); break; case 'V': nfs_version |= 1 << (atoi (optarg) - 1); break; case 'v': printf("kmountd %s\n", VERSION); exit(0); case 0: break; case '?': default: usage(argv [0], 1); } /* No more arguments allowed. * Require at least one valid version (2, 3, or 4) */ if (optind != argc || !(nfs_version & 0xE)) usage(argv [0], 1); if (chdir(state_dir)) { fprintf(stderr, "%s: chdir(%s) failed: %s\n", argv [0], state_dir, strerror(errno)); exit(1); } if (getrlimit (RLIMIT_NOFILE, &rlim) != 0) fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n", argv [0], strerror(errno)); else { /* glibc sunrpc code dies if getdtablesize > FD_SETSIZE */ if ((descriptors == 0 && rlim.rlim_cur > FD_SETSIZE) || descriptors > FD_SETSIZE) descriptors = FD_SETSIZE; if (descriptors) { rlim.rlim_cur = descriptors; if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) { fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n", argv [0], strerror(errno)); exit(1); } } } /* Initialize logging. */ if (!foreground) xlog_stderr(0); xlog_open("mountd"); sa.sa_handler = SIG_IGN; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(SIGHUP, &sa, NULL); sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sigaction(SIGPIPE, &sa, NULL); /* WARNING: the following works on Linux and SysV, but not BSD! */ sigaction(SIGCHLD, &sa, NULL); /* Daemons should close all extra filehandles ... *before* RPC init. */ if (!foreground) closeall(3); new_cache = check_new_cache(); if (new_cache) cache_open(); if (nfs_version & 0x1) rpc_init("mountd", MOUNTPROG, MOUNTVERS, mount_dispatch, port); if (nfs_version & (0x1 << 1)) rpc_init("mountd", MOUNTPROG, MOUNTVERS_POSIX, mount_dispatch, port); if (nfs_version & (0x1 << 2)) rpc_init("mountd", MOUNTPROG, MOUNTVERS_NFSV3, mount_dispatch, port); sa.sa_handler = killer; sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sa.sa_handler = sig_hup; sigaction(SIGHUP, &sa, NULL); auth_init(export_file); if (!foreground) { /* We first fork off a child. */ if ((c = fork()) > 0) exit(0); if (c < 0) { xlog(L_FATAL, "mountd: cannot fork: %s\n", strerror(errno)); } /* Now we remove ourselves from the foreground. Redirect stdin/stdout/stderr first. */ { int fd = open("/dev/null", O_RDWR); (void) dup2(fd, 0); (void) dup2(fd, 1); (void) dup2(fd, 2); if (fd > 2) (void) close(fd); } setsid(); } /* silently bounds check num_threads */ if (foreground) num_threads = 1; else if (num_threads < 1) num_threads = 1; else if (num_threads > MAX_THREADS) num_threads = MAX_THREADS; if (num_threads > 1) fork_workers(); my_svc_run(); xlog(L_ERROR, "Ack! Gack! svc_run returned!\n"); exit(1); }
int main(int argc, char **argv) { int count = 1, c, error = 0, portnum = 0, fd, found_one; char *p, *progname, *port; char *haddr = NULL; int socket_up = 0; int minorvers4 = NFSD_MAXMINORVERS4; /* nfsv4 minor version */ unsigned int versbits = NFSCTL_ALLBITS; unsigned int protobits = NFSCTL_ALLBITS; unsigned int proto4 = 0; unsigned int proto6 = 0; progname = strdup(basename(argv[0])); if (!progname) { fprintf(stderr, "%s: unable to allocate memory.\n", argv[0]); exit(1); } port = strdup("nfs"); if (!port) { fprintf(stderr, "%s: unable to allocate memory.\n", progname); exit(1); } xlog_syslog(0); xlog_stderr(1); while ((c = getopt_long(argc, argv, "dH:hN:p:P:sTU", longopts, NULL)) != EOF) { switch(c) { case 'd': xlog_config(D_ALL, 1); break; case 'H': /* * for now, this only handles one -H option. Use the * last one specified. */ free(haddr); haddr = strdup(optarg); if (!haddr) { fprintf(stderr, "%s: unable to allocate " "memory.\n", progname); exit(1); } break; case 'P': /* XXX for nfs-server compatibility */ case 'p': /* only the last -p option has any effect */ portnum = atoi(optarg); if (portnum <= 0 || portnum > 65535) { fprintf(stderr, "%s: bad port number: %s\n", progname, optarg); usage(progname); } free(port); port = strdup(optarg); if (!port) { fprintf(stderr, "%s: unable to allocate " "memory.\n", progname); exit(1); } break; case 'N': switch((c = strtol(optarg, &p, 0))) { case 4: if (*p == '.') { minorvers4 = -atoi(p + 1); break; } case 3: case 2: NFSCTL_VERUNSET(versbits, c); break; default: fprintf(stderr, "%s: Unsupported version\n", optarg); exit(1); } break; case 's': xlog_syslog(1); xlog_stderr(0); break; case 'T': NFSCTL_TCPUNSET(protobits); break; case 'U': NFSCTL_UDPUNSET(protobits); break; default: fprintf(stderr, "Invalid argument: '%c'\n", c); case 'h': usage(progname); } } if (optind < argc) { if ((count = atoi(argv[optind])) < 0) { /* insane # of servers */ fprintf(stderr, "%s: invalid server count (%d), using 1\n", argv[0], count); count = 1; } else if (count == 0) { /* * don't bother setting anything else if the threads * are coming down anyway. */ socket_up = 1; goto set_threads; } } xlog_open(progname); nfsd_enable_protos(&proto4, &proto6); if (!NFSCTL_TCPISSET(protobits)) { NFSCTL_TCPUNSET(proto4); NFSCTL_TCPUNSET(proto6); } if (!NFSCTL_UDPISSET(protobits)) { NFSCTL_UDPUNSET(proto4); NFSCTL_UDPUNSET(proto6); } /* make sure that at least one version is enabled */ found_one = 0; for (c = NFSD_MINVERS; c <= NFSD_MAXVERS; c++) { if (NFSCTL_VERISSET(versbits, c)) found_one = 1; } if (!found_one) { xlog(L_ERROR, "no version specified"); exit(1); } if (NFSCTL_VERISSET(versbits, 4) && !NFSCTL_TCPISSET(proto4) && !NFSCTL_TCPISSET(proto6)) { xlog(L_ERROR, "version 4 requires the TCP protocol"); exit(1); } if (chdir(NFS_STATEDIR)) { xlog(L_ERROR, "chdir(%s) failed: %m", NFS_STATEDIR); exit(1); } /* make sure nfsdfs is mounted if it's available */ nfssvc_mount_nfsdfs(progname); /* can only change number of threads if nfsd is already up */ if (nfssvc_inuse()) { socket_up = 1; goto set_threads; } /* * must set versions before the fd's so that the right versions get * registered with rpcbind. Note that on older kernels w/o the right * interfaces, these are a no-op. */ nfssvc_setvers(versbits, minorvers4); error = nfssvc_set_sockets(AF_INET, proto4, haddr, port); if (!error) socket_up = 1; #ifdef IPV6_SUPPORTED error = nfssvc_set_sockets(AF_INET6, proto6, haddr, port); if (!error) socket_up = 1; #endif /* IPV6_SUPPORTED */ set_threads: /* don't start any threads if unable to hand off any sockets */ if (!socket_up) { xlog(L_ERROR, "unable to set any sockets for nfsd"); goto out; } error = 0; /* * KLUDGE ALERT: * Some kernels let nfsd kernel threads inherit open files * from the program that spawns them (i.e. us). So close * everything before spawning kernel threads. --Chip */ fd = open("/dev/null", O_RDWR); if (fd == -1) xlog(L_ERROR, "Unable to open /dev/null: %m"); else { /* switch xlog output to syslog since stderr is being closed */ xlog_syslog(1); xlog_stderr(0); (void) dup2(fd, 0); (void) dup2(fd, 1); (void) dup2(fd, 2); } closeall(3); if ((error = nfssvc_threads(portnum, count)) < 0) xlog(L_ERROR, "error starting threads: errno %d (%m)", errno); out: free(port); free(haddr); free(progname); return (error != 0); }
int main(int argc, char **argv) { char *options = NULL; char *progname = NULL; int f_export = 1; int f_all = 0; int f_verbose = 0; int f_export_format = 0; int f_reexport = 0; int f_ignore = 0; int i, c; int new_cache = 0; int force_flush = 0; if ((progname = strrchr(argv[0], '/')) != NULL) progname++; else progname = argv[0]; xlog_open(progname); xlog_stderr(1); xlog_syslog(0); while ((c = getopt(argc, argv, "afhio:ruvs")) != EOF) { switch(c) { case 'a': f_all = 1; break; case 'f': force_flush = 1; break; case 'h': usage(progname, 0); break; case 'i': f_ignore = 1; break; case 'o': options = optarg; break; case 'r': f_reexport = 1; f_all = 1; break; case 'u': f_export = 0; break; case 'v': f_verbose = 1; break; case 's': f_export_format = 1; break; default: usage(progname, 1); break; } } if (optind != argc && f_all) { xlog(L_ERROR, "extra arguments are not permitted with -a or -r"); return 1; } if (f_ignore && (f_all || ! f_export)) { xlog(L_ERROR, "-i not meaningful with -a, -r or -u"); return 1; } if (f_reexport && ! f_export) { xlog(L_ERROR, "-r and -u are incompatible"); return 1; } new_cache = check_new_cache(); if (optind == argc && ! f_all) { if (force_flush) { if (new_cache) cache_flush(1); else { xlog(L_ERROR, "-f is available only " "with new cache controls. " "Mount /proc/fs/nfsd first"); return 1; } return 0; } else { xtab_export_read(); dump(f_verbose, f_export_format); return 0; } } /* * Serialize things as best we can */ grab_lockfile(); atexit(release_lockfile); if (f_export && ! f_ignore) { export_read(_PATH_EXPORTS); export_d_read(_PATH_EXPORTS_D); } if (f_export) { if (f_all) export_all(f_verbose); else for (i = optind; i < argc ; i++) exportfs(argv[i], options, f_verbose); } /* If we are unexporting everything, then * don't care about what should be exported, as that * may require DNS lookups.. */ if (! ( !f_export && f_all)) { /* note: xtab_*_read does not update entries if they already exist, * so this will not lose new options */ if (!f_reexport) xtab_export_read(); if (!f_export) for (i = optind ; i < argc ; i++) unexportfs(argv[i], f_verbose); if (!new_cache) rmtab_read(); } if (!new_cache) { xtab_mount_read(); exports_update(f_verbose); } xtab_export_write(); if (new_cache) cache_flush(force_flush); if (!new_cache) xtab_mount_write(); return export_errno; }
/** * Program entry point * * @param argc count of command line arguments * @param argv array of NUL-terminated C strings containing command line arguments * @return program exit status */ int main(int argc, char **argv) { char *progname, *nsdbname; unsigned short nsdbport; unsigned int ldap_err; FedFsStatus retval; nsdb_t host; char *nce; int arg; (void)setlocale(LC_ALL, ""); (void)umask(S_IRWXO); /* Set the basename */ if ((progname = strrchr(argv[0], '/')) != NULL) progname++; else progname = argv[0]; /* For the libraries */ xlog_stderr(1); xlog_syslog(0); xlog_open(progname); nsdb_env(&nsdbname, &nsdbport, NULL, &nce); while ((arg = getopt_long(argc, argv, nsdb_list_opts, nsdb_list_longopts, NULL)) != -1) { switch (arg) { case 'd': xlog_config(D_ALL, 1); nsdb_enable_ldap_debugging(); break; case 'e': nce = optarg; break; case 'l': nsdbname = optarg; break; case 'r': if (!nsdb_parse_port_string(optarg, &nsdbport)) { fprintf(stderr, "Bad port number: %s\n", optarg); nsdb_list_usage(progname); } break; default: fprintf(stderr, "Invalid command line " "argument: %c\n", (char)arg); case '?': nsdb_list_usage(progname); } } if (optind != argc) { fprintf(stderr, "Unrecognized command line argument\n"); nsdb_list_usage(progname); } if (nsdbname == NULL) { fprintf(stderr, "Missing required command line argument\n"); nsdb_list_usage(progname); } retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host); switch (retval) { case FEDFS_OK: break; case FEDFS_ERR_NSDB_PARAMS: fprintf(stderr, "No connection parameters for NSDB %s:%u\n", nsdbname, nsdbport); goto out; default: fprintf(stderr, "Failed to look up NSDB %s:%u: %s\n", nsdbname, nsdbport, nsdb_display_fedfsstatus(retval)); goto out; } again: retval = nsdb_open_nsdb(host, NULL, NULL, &ldap_err); switch (retval) { case FEDFS_OK: break; case FEDFS_ERR_NSDB_CONN: fprintf(stderr, "Failed to connect to NSDB %s:%u\n", nsdbname, nsdbport); goto out_free; case FEDFS_ERR_NSDB_AUTH: fprintf(stderr, "Failed to establish secure connection " "to NSDB %s:%u\n", nsdbname, nsdbport); goto out_free; case FEDFS_ERR_NSDB_LDAP_VAL: fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n", nsdbname, nsdbport, ldap_err2string(ldap_err)); goto out_free; default: fprintf(stderr, "Failed to open NSDB %s:%u: %s\n", nsdbname, nsdbport, nsdb_display_fedfsstatus(retval)); goto out_free; } if (nce != NULL) retval = nsdb_list_display_nce(host, nce, &ldap_err); else retval = nsdb_list_display_all_nces(host, &ldap_err); if (retval == FEDFS_ERR_NSDB_LDAP_VAL) { switch (ldap_err) { case LDAP_REFERRAL: retval = nsdb_list_follow_ldap_referral(&host); if (retval == FEDFS_OK) goto again; break; case LDAP_CONFIDENTIALITY_REQUIRED: fprintf(stderr, "TLS security required for %s:%u\n", nsdbname, nsdbport); break; default: fprintf(stderr, "Failed to list FSNs: %s\n", ldap_err2string(ldap_err)); } } nsdb_close_nsdb(host); out_free: nsdb_free_nsdb(host); out: exit((int)retval); }
int main(int argc, char **argv) { char *arg; char *value; char *type; int rc = 1, opt; int timeout = 600; key_serial_t key; char *progname, *keystr = NULL; int clearing = 0, keymask = 0, display = 0, list = 0; /* Set the basename */ if ((progname = strrchr(argv[0], '/')) != NULL) progname++; else progname = argv[0]; xlog_open(progname); while ((opt = getopt(argc, argv, "du:g:r:ct:vl")) != -1) { switch (opt) { case 'd': display++; break; case 'l': list++; break; case 'u': keymask = UIDKEYS; keystr = strdup(optarg); break; case 'g': keymask = GIDKEYS; keystr = strdup(optarg); break; case 'r': keymask = GIDKEYS|UIDKEYS; keystr = strdup(optarg); break; case 'c': clearing++; break; case 'v': verbose++; break; case 't': timeout = atoi(optarg); break; default: xlog_warn(usage, progname); break; } } if ((rc = nfs4_init_name_mapping(PATH_IDMAPDCONF))) { xlog_errno(rc, "Unable to create name to user id mappings."); return EXIT_FAILURE; } if (!verbose) verbose = conf_get_num("General", "Verbosity", 0); if (display) return display_default_domain(); if (list) return list_keyring(DEFAULT_KEYRING); if (keystr) { return key_invalidate(keystr, keymask); } if (clearing) { xlog_syslog(0); return keyring_clear(DEFAULT_KEYRING); } xlog_stderr(0); if ((argc - optind) != 2) { xlog_err("Bad arg count. Check /etc/request-key.conf"); xlog_warn(usage, progname); return EXIT_FAILURE; } if (verbose) nfs4_set_debug(verbose, NULL); key = strtol(argv[optind++], NULL, 10); arg = strdup(argv[optind]); if (arg == NULL) { xlog_err("strdup failed: %m"); return EXIT_FAILURE; } type = strtok(arg, ":"); value = strtok(NULL, ":"); if (value == NULL) { free(arg); xlog_err("Error: Null uid/gid value."); return EXIT_FAILURE; } if (verbose) { xlog_warn("key: 0x%lx type: %s value: %s timeout %ld", key, type, value, timeout); } /* Become a possesor of the to-be-instantiated key to set the key's timeout */ request_key("keyring", DEFAULT_KEYRING, NULL, KEY_SPEC_THREAD_KEYRING); if (strcmp(type, "uid") == 0) rc = id_lookup(value, key, USER); else if (strcmp(type, "gid") == 0) rc = id_lookup(value, key, GROUP); else if (strcmp(type, "user") == 0) rc = name_lookup(value, key, USER); else if (strcmp(type, "group") == 0) rc = name_lookup(value, key, GROUP); /* Set timeout to 10 (600 seconds) minutes */ if (rc == EXIT_SUCCESS) keyctl_set_timeout(key, timeout); free(arg); return rc; }