/* * Copyright 2008 Red Hat, Inc. * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This Program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this Program; if not, write to the * * Free Software Foundation, Inc. * 59 Temple Place, Suite 330 * Boston, MA 02111-1307 USA * */ #ifdef HAVE_CONFIG_H #include "../config.h" #endif #include #include #include #include "defs-nis.h" #define DEFAULT_ENTRY_FILTER "(&(nisMapName=%m)(objectClass=nisObject))" #define DEFAULT_KEY_FORMAT NULL #define DEFAULT_KEYS_FORMAT "%{cn}" #define DEFAULT_VALUE_FORMAT "%{nisMapEntry}" #define DEFAULT_DISALLOWED_CHARS NULL #define DEFAULT_MAP_SECURE FALSE static struct configuration { char *map; enum { config_exact, config_glob } config_match; bool_t secure; char *filter; char *key_format, *keys_format, *value_format, *disallowed_chars; } config[] = { {"passwd.byname", config_exact, FALSE, "(objectClass=posixAccount)", "%{uid}", NULL, "%{uid}:%regsub(\"userPassword\",\"^\\\\{CRYPT\\\\}(..*)\",\"%1\",\"*\"):%{uidNumber}:%{gidNumber}:%{gecos:-%{cn:-}}:%{homeDirectory:-/}:%{loginShell}", ":"}, {"passwd.byuid", config_exact, FALSE, "(objectClass=posixAccount)", "%{uidNumber}", NULL, "%{uid}:%regsub(\"userPassword\",\"^\\\\{CRYPT\\\\}(..*)\",\"%1\",\"*\"):%{uidNumber}:%{gidNumber}:%{gecos:-%{cn:-}}:%{homeDirectory:-/}:%{loginShell}", ":"}, {"group.byname", config_exact, FALSE, "(objectClass=posixGroup)", "%{cn}", NULL, "%{cn}:%regsub(\"userPassword\",\"^\\\\{CRYPT\\\\}(..*)\",\"%1\",\"*\"):%{gidNumber}:%merge(\",\",\"%{memberUid}\",\"%deref(\\\"member\\\",\\\"uid\\\")\",\"%deref(\\\"uniqueMember\\\",\\\"uid\\\")\",\"%referred(\\\"passwd.byname\\\",\\\"memberOf\\\",\\\"uid\\\")\")", ":,"}, {"group.bygid", config_exact, FALSE, "(objectClass=posixGroup)", "%{gidNumber}", NULL, "%{cn}:%regsub(\"userPassword\",\"^\\\\{CRYPT\\\\}(..*)\",\"%1\",\"*\"):%{gidNumber}:%merge(\",\",\"%{memberUid}\",\"%deref(\\\"member\\\",\\\"uid\\\")\",\"%deref(\\\"uniqueMember\\\",\\\"uid\\\")\",\"%referred(\\\"passwd.byname\\\",\\\"memberOf\\\",\\\"uid\\\")\")", ":,"}, {"netgroup", config_exact, FALSE, "(objectClass=nisNetgroup)", "%{cn}", NULL, "%list(\" \",\"nisNetgroupTriple\",\"memberNisNetgroup\")", NULL}, {"auto.*", config_glob, FALSE, "(objectClass=automount)", "%{automountKey}", NULL, "%{automountInformation}", NULL}, {"ethers.byaddr", config_exact, FALSE, "(&(ipHostNumber=*)(macAddress=*))", "%{macAddress}", NULL, "%{ipHostNumber}", NULL}, {"ethers.byname", config_exact, FALSE, "(&(ipHostNumber=*)(macAddress=*))", "%{ipHostNumber}", NULL, "%{macAddress}", NULL}, {"hosts.byaddr", config_exact, FALSE, "(&(ipHostNumber=*)(cn=*))", "%{cn}", NULL, "%first(\"cn\")\t%{ipHostNumber} %list(\" \",\"cn\")", NULL}, {"hosts.byname", config_exact, FALSE, "(&(ipHostNumber=*)(cn=*))", "%{cn}", NULL, "%first(\"cn\")\t%{ipHostNumber} %list(\" \",\"cn\")", NULL}, {"mail.byaddr", config_exact, FALSE, "(objectClass=nisMailAlias)", "%{rfc822MailMember}", NULL, "%list(\",\",\"cn\")", NULL}, {"mail.aliases", config_exact, FALSE, "(objectClass=nisMailAlias)", "%{cn}", NULL, "%list(\",\",\"rfc822MailMember\")", NULL}, {"netgroup.byuser", config_exact, FALSE, "(objectClass=nisNetgroup)", NULL, NULL, NULL, NULL}, {"netgroup.byhost", config_exact, FALSE, "(objectClass=nisNetgroup)", NULL, NULL, NULL, NULL}, {"netid.byname", config_exact, FALSE, "(objectClass=posixAccount)", "unix.%{uidNumber}", NULL, "%{uidNumber}:%merge(\",\",\"%{gidNumber}\",\"%deref(\\\"memberOf\\\",\\\"gidNumber\\\")\",\"%referred(\\\"group.byname\\\",\\\"member\\\",\\\"gidNumber\\\")\",\"%referred(\\\"group.byname\\\",\\\"uniqueMember\\\",\\\"gidNumber\\\")\")", NULL}, {"networks.byaddr", config_exact, FALSE, "(objectClass=ipNetwork)", "%{ipNetworkNumber}", NULL, "%{cn}", NULL}, {"networks.byname", config_exact, FALSE, "(objectClass=ipNetwork)", "%{cn}", NULL, "%{ipNetworkNumber}", NULL}, {"protocols.byname", config_exact, FALSE, "(objectClass=ipProtocol)", "%{cn}", NULL, "%first(\"cn\")\t%{ipProtocolNumber}\t%list(\" \",\"cn\")", NULL}, {"protocols.bynumber", config_exact, FALSE, "(objectClass=ipProtocol)", "%{cn}", NULL, "%first(\"cn\")\t%{ipProtocolNumber}\t%list(\" \",\"cn\")", NULL}, {"rpc.byname", config_exact, FALSE, "(objectClass=oncRpc)", "%{cn}", NULL, "%first(\"cn\")\t%{oncRpcNumber}\t%list(\" \",\"cn\")", NULL}, {"rpc.bynumber", config_exact, FALSE, "(objectClass=oncRpc)", "%{oncRpcNumber}", NULL, "%first(\"cn\")\t%{oncRpcNumber}\t%list(\" \",\"cn\")", NULL}, {"services.byname", config_exact, FALSE, "(objectClass=ipService)", NULL, NULL, NULL, NULL}, {"services.byservicename", config_exact, FALSE, "(objectClass=ipService)", NULL, NULL, NULL, NULL}, }; void defaults_get_map_config(const char *mapname, bool_t *secure, const char **filter, const char **key_format, const char **keys_format, const char **value_format, const char **disallowed_chars) { unsigned int i; for (i = 0; i < sizeof(config) / sizeof(config[0]); i++) { bool_t match; match = FALSE; switch (config[i].config_match) { case config_exact: if (strcmp(config[i].map, mapname) == 0) { match = TRUE; } break; case config_glob: if (fnmatch(config[i].map, mapname, FNM_NOESCAPE) == 0) { match = TRUE; } break; } if (!match) { continue; } if (secure) { *secure = config[i].secure; } if (filter) { *filter = config[i].filter; } if (key_format) { *key_format = config[i].key_format; } if (keys_format) { *keys_format = config[i].keys_format; } if (value_format) { *value_format = config[i].value_format; } if (disallowed_chars) { *disallowed_chars = config[i].disallowed_chars; } break; } if (i >= (sizeof(config) / sizeof(config[0]))) { if (secure) { *secure = DEFAULT_MAP_SECURE; } if (filter) { *filter = DEFAULT_ENTRY_FILTER; } if (key_format) { *key_format = DEFAULT_KEY_FORMAT; } if (keys_format) { *keys_format = DEFAULT_KEYS_FORMAT; } if (value_format) { *value_format = DEFAULT_VALUE_FORMAT; } if (disallowed_chars) { *disallowed_chars = DEFAULT_DISALLOWED_CHARS; } } }