Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-07-26 22:11:41 +0200
committerArthur de Jong <arthur@arthurdejong.org>2007-07-26 22:11:41 +0200
commit76d4d5066d5aef3a380b182f1eef79e8bbbc6d9f (patch)
treecd2af611ff3fad4e2635944cd26783520d5a1be6
parent5f21d0c7bcf5845b53ff94dd054fb1be9692a777 (diff)
remove some more old mapping stuff and change configuration file keyword to map with the new syntax
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@332 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--nslcd/cfg.c64
-rw-r--r--nslcd/ldap-schema.h139
2 files changed, 23 insertions, 180 deletions
diff --git a/nslcd/cfg.c b/nslcd/cfg.c
index 94e5511..9bfbe29 100644
--- a/nslcd/cfg.c
+++ b/nslcd/cfg.c
@@ -55,8 +55,7 @@ struct ldap_config *nslcd_cfg=NULL;
#define LDAP_NSS_MAXSLEEPTIME 64 /* maximum seconds to sleep */
#define LDAP_NSS_MAXCONNTRIES 2 /* reconnect attempts before sleeping */
-#define NSS_LDAP_KEY_MAP_ATTRIBUTE "nss_map_attribute"
-#define NSS_LDAP_KEY_MAP_OBJECTCLASS "nss_map_objectclass"
+#define NSS_LDAP_KEY_MAP "map"
#define NSS_LDAP_KEY_SCOPE "scope"
#define NSS_LDAP_KEY_BASE "base"
#define NSS_LDAP_KEY_BINDDN "binddn"
@@ -263,48 +262,37 @@ static enum ldap_map_selector _nss_ldap_str2selector(const char *key)
return sel;
}
+/* this function modifies the statement argument passed */
static enum nss_status do_parse_map_statement(
- struct ldap_config *cfg,char *statement,
- enum ldap_map_type type)
+ struct ldap_config *cfg,char *statement)
{
char *key,*val;
- enum ldap_map_selector sel=LM_NONE;
- char *p;
const char **var;
key=(char *)statement;
val=key;
+ /* search for the end of the key */
while (*val!=' '&&*val!='\t')
val++;
*(val++)='\0';
+ /* search for the end of the value */
while (*val==' '||*val=='\t')
val++;
- p=strchr(key,':');
- if (p!=NULL)
+ /* special handling for some attribute mappings */
+ if (strcasecmp(key,"passwd.userPassword")==0)
{
- *p='\0';
- sel=_nss_ldap_str2selector(key);
- key=++p;
+ if (strcasecmp(val,"userPassword")==0)
+ cfg->ldc_password_type=LU_RFC2307_USERPASSWORD;
+ else if (strcasecmp (val,"authPassword")==0)
+ cfg->ldc_password_type=LU_RFC3112_AUTHPASSWORD;
+ else
+ cfg->ldc_password_type=LU_OTHER_PASSWORD;
}
-
- if (type==MAP_ATTRIBUTE)
+ else if (strcasecmp(key,"shadow.shadowLastChange")==0)
{
- /* special handling for attribute mapping */
- if (strcasecmp(key,"passwd.userPassword")==0)
- {
- if (strcasecmp(val,"userPassword")==0)
- cfg->ldc_password_type=LU_RFC2307_USERPASSWORD;
- else if (strcasecmp (val,"authPassword")==0)
- cfg->ldc_password_type=LU_RFC3112_AUTHPASSWORD;
- else
- cfg->ldc_password_type=LU_OTHER_PASSWORD;
- }
- else if (strcasecmp(key,"shadow.shadowLastChange")==0)
- {
- if (strcasecmp(val,"shadowLastChange")==0)
- cfg->ldc_shadow_type=LS_RFC2307_SHADOW;
- else if (strcasecmp (val,"pwdLastSet")==0)
- cfg->ldc_shadow_type=LS_AD_SHADOW;
- }
+ if (strcasecmp(val,"shadowLastChange")==0)
+ cfg->ldc_shadow_type=LS_RFC2307_SHADOW;
+ else if (strcasecmp (val,"pwdLastSet")==0)
+ cfg->ldc_shadow_type=LS_AD_SHADOW;
}
var=attmap_get_var(key);
if (var==NULL)
@@ -313,9 +301,8 @@ static enum nss_status do_parse_map_statement(
/* check if the value actually changed */
if (strcmp(*var,val)!=0)
{
- /* Note: we have a memory leak here if a single mapping is
- changed multiple times in one config
- (deemed not a problem) */
+ /* Note: we have a memory leak here if a single mapping is changed
+ multiple times in one config (deemed not a problem) */
*var=strdup(val);
if (*var==NULL)
/* memory allocation failed */
@@ -753,15 +740,10 @@ static enum nss_status _nss_ldap_readconfig(struct ldap_config ** presult, char
{
t = &result->ldc_tls_randfile;
}
- else if (!strncasecmp (k, NSS_LDAP_KEY_MAP_ATTRIBUTE,
- strlen (NSS_LDAP_KEY_MAP_ATTRIBUTE)))
- {
- do_parse_map_statement (result, v, MAP_ATTRIBUTE);
- }
- else if (!strncasecmp (k, NSS_LDAP_KEY_MAP_OBJECTCLASS,
- strlen (NSS_LDAP_KEY_MAP_OBJECTCLASS)))
+ else if (!strncasecmp (k, NSS_LDAP_KEY_MAP,
+ strlen (NSS_LDAP_KEY_MAP)))
{
- do_parse_map_statement (result, v, MAP_OBJECTCLASS);
+ do_parse_map_statement (result, v);
}
else if (!strcasecmp (k, NSS_LDAP_KEY_INITGROUPS))
{
diff --git a/nslcd/ldap-schema.h b/nslcd/ldap-schema.h
index 94471d6..60bb0e7 100644
--- a/nslcd/ldap-schema.h
+++ b/nslcd/ldap-schema.h
@@ -93,145 +93,6 @@ extern char _nss_ldap_filt_getspent[];
/* netgroups */
extern char _nss_ldap_filt_getnetgrent[];
-/**
- * Common attributes, not from RFC 2307.
- */
-#define AT_objectClass "objectClass"
-#define AT_cn "cn"
-
-/**
- * Vendor-specific attributes and object classes.
- * (Mainly from Sun.)
- */
-#define OC_nisMailAlias "nisMailAlias"
-#define AT_rfc822MailMember "rfc822MailMember"
-
-/**
- * RFC 2307 attributes and object classes.
- */
-
-/*
- * ( nisSchema.2.0 NAME 'posixAccount' SUP top AUXILIARY
- * DESC 'Abstraction of an account with POSIX attributes'
- * MUST ( cn $ uid $ uidNumber $ gidNumber $ homeDirectory )
- * MAY ( userPassword $ loginShell $ gecos $ description ) )
- */
-#define OC_posixAccount "posixAccount"
-#define AT_uid "uid"
-#define AT_userPassword "userPassword"
-#define AT_uidNumber "uidNumber"
-#define AT_gidNumber "gidNumber"
-#define AT_loginShell "loginShell"
-#define AT_gecos "gecos"
-#define AT_homeDirectory "homeDirectory"
-
-/*
- * ( nisSchema.2.1 NAME 'shadowAccount' SUP top AUXILIARY
- * DESC 'Additional attributes for shadow passwords'
- * MUST uid
- * MAY ( userPassword $ shadowLastChange $ shadowMin
- * shadowMax $ shadowWarning $ shadowInactive $
- * shadowExpire $ shadowFlag $ description ) )
- */
-#define OC_shadowAccount "shadowAccount"
-#define AT_shadowLastChange "shadowLastChange"
-#define AT_shadowMin "shadowMin"
-#define AT_shadowMax "shadowMax"
-#define AT_shadowWarning "shadowWarning"
-#define AT_shadowInactive "shadowInactive"
-#define AT_shadowExpire "shadowExpire"
-#define AT_shadowFlag "shadowFlag"
-
-/*
- * ( nisSchema.2.2 NAME 'posixGroup' SUP top STRUCTURAL
- * DESC 'Abstraction of a group of accounts'
- * MUST ( cn $ gidNumber )
- * MAY ( userPassword $ uidMember $ description ) )
- */
-#define OC_posixGroup "posixGroup"
-#define AT_gidNumber "gidNumber"
-#define AT_memberUid "memberUid"
-#define AT_uniqueMember "uniqueMember"
-#define AT_memberOf "memberOf"
-
-/*
- * ( nisSchema.2.3 NAME 'ipService' SUP top STRUCTURAL
- * DESC 'Abstraction an Internet Protocol service.
- * Maps an IP port and protocol (such as tcp or udp)
- * to one or more names; the distinguished value of
- * the cn attribute denotes the service's canonical
- * name'
- * MUST ( cn $ ipServicePort $ ipServiceProtocol )
- * MAY ( description ) )
- */
-#define OC_ipService "ipService"
-#define AT_ipServicePort "ipServicePort"
-#define AT_ipServiceProtocol "ipServiceProtocol"
-
-/*
- * ( nisSchema.2.4 NAME 'ipProtocol' SUP top STRUCTURAL
- * DESC 'Abstraction of an IP protocol. Maps a protocol number
- * to one or more names. The distinguished value of the cn
- * attribute denotes the protocol's canonical name'
- * MUST ( cn $ ipProtocolNumber )
- * MAY description )
- */
-#define OC_ipProtocol "ipProtocol"
-#define AT_ipProtocolNumber "ipProtocolNumber"
-
-/*
- * ( nisSchema.2.5 NAME 'oncRpc' SUP top STRUCTURAL
- * DESC 'Abstraction of an Open Network Computing (ONC)
- * [RFC1057] Remote Procedure Call (RPC) binding.
- * This class maps an ONC RPC number to a name.
- * The distinguished value of the cn attribute denotes
- * the RPC service's canonical name'
- * MUST ( cn $ oncRpcNumber )
- * MAY description )
- */
-#define OC_oncRpc "oncRpc"
-#define AT_oncRpcNumber "oncRpcNumber"
-
-/*
- * ( nisSchema.2.6 NAME 'ipHost' SUP top AUXILIARY
- * DESC 'Abstraction of a host, an IP device. The distinguished
- * value of the cn attribute denotes the host's canonical
- * name. Device SHOULD be used as a structural class'
- * MUST ( cn $ ipHostNumber )
- * MAY ( l $ description $ manager ) )
- */
-#define OC_ipHost "ipHost"
-#define AT_ipHostNumber "ipHostNumber"
-
-/*
- * ( nisSchema.2.7 NAME 'ipNetwork' SUP top STRUCTURAL
- * DESC 'Abstraction of a network. The distinguished value of
- * MUST ( cn $ ipNetworkNumber )
- * MAY ( ipNetmaskNumber $ l $ description $ manager ) )
- */
-#define OC_ipNetwork "ipNetwork"
-#define AT_ipNetworkNumber "ipNetworkNumber"
-#define AT_ipNetmaskNumber "ipNetmaskNumber"
-
-/*
- * ( nisSchema.2.8 NAME 'nisNetgroup' SUP top STRUCTURAL
- * DESC 'Abstraction of a netgroup. May refer to other netgroups'
- * MUST cn
- * MAY ( nisNetgroupTriple $ memberNisNetgroup $ description ) )
- */
-#define OC_nisNetgroup "nisNetgroup"
-#define AT_nisNetgroupTriple "nisNetgroupTriple"
-#define AT_memberNisNetgroup "memberNisNetgroup"
-
-/*
- * ( nisSchema.2.11 NAME 'ieee802Device' SUP top AUXILIARY
- * DESC 'A device with a MAC address; device SHOULD be
- * used as a structural class'
- * MAY macAddress )
- */
-#define OC_ieee802Device "ieee802Device"
-#define AT_macAddress "macAddress"
-
/*
* Map names
*/