/*! ***************************************************************************** * ****************************************************************************/ int optdb_find(int opt, char *path) { int i = 0; if (opt == OPT_KEY_EXCLUDE) { while (i != OPT_CNT(opt)) { char *tmp = OPT_STR(OPT_KEY_EXCLUDE, i); char *safe_path = strdup(path); if (!strcmp(basename(safe_path), tmp ? tmp : "")) { free(safe_path); return 1; } free(safe_path); ++i; } } else if (opt == OPT_KEY_FAKE_ISO || opt == OPT_KEY_IMG_TYPE) { int l = get_ext_len(path); if (l <= 1) return 0; while (i != OPT_CNT(opt)) { char *tmp = OPT_STR(opt, i); if (!strcmp((path) + (strlen(path) - l), tmp ? tmp : "")) return l - 1; ++i; } } return 0; }
OPT_FLAG(flagstorefrom,'F',0,0), OPT_FLAG(flaglist,'l',1,"modcanlist"), OPT_FLAG(flaglist,'L',0,0), OPT_FLAG(flagunsubismod,'m',1,0), OPT_FLAG(flagunsubismod,'M',0,0), OPT_FLAG(flagnotify,'n',1,0), OPT_FLAG(flagnotify,'N',0,0), OPT_FLAG(flagsubconf,'s',1,0), OPT_FLAG(flagsubconf,'S',0,"nosubconfirm"), OPT_FLAG(flagcopyowner,'q',0,0), OPT_COUNTER(flagcopyowner,'Q',1,0), OPT_FLAG(flagunsubconf,'u',1,0), OPT_FLAG(flagunsubconf,'U',0,"nounsubconfirm"), OPT_ULONG(copylines,0,"copylines"), OPT_FLAG(flagpublic,0,1,"public"), OPT_STR(modsub,0,"modsub"), OPT_STR(remote,0,"remote"), OPT_END }; static const char hex[]="0123456789ABCDEF"; static char urlstr[] = "%00"; /* to build a url-encoded version of a char */ static const char *dir; static const char *workdir; static const char *sender; static void die_cookie(void) { strerr_die2x(100,FATAL,MSG(ERR_MOD_COOKIE)); }
}; /* helper macros for declaring config_options */ #define OPT_INT(key,def,field) \ { key, def, TYPE_INT, FIELD_OFFSET(struct idmap_config, field), 0 } #define OPT_STR(key,def,field,len) \ { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, field), len } #define OPT_CLASS(key,def,index) \ { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, classes[index]), NAME_LEN } #define OPT_ATTR(key,def,index) \ { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, attributes[index]), NAME_LEN } /* table of recognized config options, including type and default value */ static const struct config_option g_options[] = { /* server information */ OPT_STR("ldap_hostname", "localhost", hostname, NFS41_HOSTNAME_LEN+1), OPT_INT("ldap_port", "389", port), OPT_INT("ldap_version", "3", version), OPT_INT("ldap_timeout", "0", timeout), /* schema information */ OPT_STR("ldap_base", "cn=localhost", base, VAL_LEN), OPT_CLASS("ldap_class_users", "user", CLASS_USER), OPT_CLASS("ldap_class_groups", "group", CLASS_GROUP), OPT_ATTR("ldap_attr_username", "cn", ATTR_USER_NAME), OPT_ATTR("ldap_attr_groupname", "cn", ATTR_GROUP_NAME), OPT_ATTR("ldap_attr_gssAuthName", "gssAuthName", ATTR_PRINCIPAL), OPT_ATTR("ldap_attr_uidNumber", "uidNumber", ATTR_UID), OPT_ATTR("ldap_attr_gidNumber", "gidNumber", ATTR_GID), /* caching configuration */