- struct passwd *pw;
- char *dumpuser;
- int fd;
- disklist_t *diskqp;
- char *conffile;
- char *conf_diskfile;
- char *conf_infofile;
-
- for(fd = 3; fd < FD_SETSIZE; fd++) {
- /*
- * Make sure nobody spoofs us with a lot of extra open files
- * that would cause an open we do to get a very high file
- * descriptor, which in turn might be used as an index into
- * an array (e.g. an fd_set).
- */
- close(fd);
- }
-
- safe_cd();
-
- set_pname("amcleanupdisk");
-
- if(main_argc != 2) {
- error("Usage: amcleanupdisk%s <confdir>", versionsuffix());
- }
-
- config_name = main_argv[1];
-
- config_dir = vstralloc(CONFIG_DIR, "/", config_name, "/", NULL);
- conffile = stralloc2(config_dir, CONFFILE_NAME);
- if(read_conffile(conffile)) {
- error("errors processing config file \"%s\"", conffile);
- }
- amfree(conffile);
- conf_diskfile = getconf_str(CNF_DISKFILE);
- if (*conf_diskfile == '/') {
- conf_diskfile = stralloc(conf_diskfile);
- } else {
- conf_diskfile = stralloc2(config_dir, conf_diskfile);
- }
- if((diskqp = read_diskfile(conf_diskfile)) == NULL) {
- error("could not load disklist %s", conf_diskfile);
- }
- amfree(conf_diskfile);
- conf_infofile = getconf_str(CNF_INFOFILE);
- if (*conf_infofile == '/') {
- conf_infofile = stralloc(conf_infofile);
- } else {
- conf_infofile = stralloc2(config_dir, conf_infofile);
- }
- if(open_infofile(conf_infofile)) {
- error("could not open info db \"%s\"", conf_infofile);