54
54
int mysnprintf(char *buffer,size_t buflen,const char *format, ...)
57
/* return the fully qualified domain name of the current host
58
the returned value does not need to be freed but is re-used for every
60
MUST_USE const char *getfqdn(void);
57
62
/* This tries to get the user password attribute from the entry.
58
63
It will try to return an encrypted password as it is used in /etc/passwd,
59
64
/etc/group or /etc/shadow depending upon what is in the directory.
60
65
This function will return NULL if no passwd is found and will return the
61
66
literal value in the directory if conversion is not possible. */
62
const char *get_userpassword(MYLDAP_ENTRY *entry,const char *attr);
67
const char *get_userpassword(MYLDAP_ENTRY *entry,const char *attr,
68
char *buffer,size_t buflen);
64
70
/* write out an address, parsing the addr value */
65
71
int write_address(TFILE *fp,const char *addr);
78
84
if (read_address(fp,addr,&(len),&(af))) \
87
/* convert the provided string representation of a sid
88
(e.g. S-1-5-21-1936905831-823966427-12391542-23578)
89
to a format that can be used to search the objectSid property with */
90
MUST_USE char *sid2search(const char *sid);
92
/* return the last security identifier of the binary sid */
93
MUST_USE long int binsid2id(const char *binsid);
81
95
/* checks to see if the specified string is a valid user or group name */
82
96
MUST_USE int isvalidname(const char *name);
84
98
/* Perform an LDAP lookup to translate the DN into a uid.
85
99
This function either returns NULL or a strdup()ed string. */
86
MUST_USE char *lookup_dn2uid(MYLDAP_SESSION *session,const char *dn,int *rcp);
100
MUST_USE char *lookup_dn2uid(MYLDAP_SESSION *session,const char *dn,int *rcp,char *buf,size_t buflen);
88
102
/* transforms the DN info a uid doing an LDAP lookup if needed */
89
103
MUST_USE char *dn2uid(MYLDAP_SESSION *session,const char *dn,char *buf,size_t buflen);
91
105
/* use the user id to lookup an LDAP entry */
92
MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *session,const char *uid);
106
MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *session,const char *uid,int *rcp);
94
108
/* transforms the uid into a DN by doing an LDAP lookup */
95
109
MUST_USE char *uid2dn(MYLDAP_SESSION *session,const char *uid,char *buf,size_t buflen);
111
/* try to update the shadowLastChange attribute of the entry if possible */
112
int update_lastchange(MYLDAP_SESSION *session,const char *userdn);
114
/* use the user id to lookup an LDAP entry with the shadow attributes
116
MYLDAP_ENTRY *shadow_uid2entry(MYLDAP_SESSION *session,const char *username,int *rcp);
118
/* return shadown information */
119
void get_shadow_properties(MYLDAP_ENTRY *entry,long *lastchangedate,
120
long *mindays,long *maxdays,long *warndays,
121
long *inactdays,long *expiredate,unsigned long *flag);
124
/* check whether the nsswitch.conf file has LDAP as a naming source for db */
125
int nsswitch_db_uses_ldap(const char *filename,const char *db);
127
/* fallback definition of HOST_NAME_MAX */
128
#ifndef HOST_NAME_MAX
129
#ifdef _POSIX_HOST_NAME_MAX
130
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
132
#define HOST_NAME_MAX 255
133
#endif /* _POSIX_HOST_NAME_MAX */
134
#endif /* not HOST_NAME_MAX */
136
/* provide strtouid() function alias */
137
#if SIZEOF_UID_T == SIZEOF_UNSIGNED_LONG_INT
138
#define strtouid (uid_t)strtoul
139
#elif SIZEOF_UID_T == SIZEOF_UNSIGNED_LONG_LONG_INT
140
#define strtouid (uid_t)strtoull
141
#elif SIZEOF_UID_T == SIZEOF_UNSIGNED_INT
142
#define WANT_STRTOUI 1
143
#define strtouid (uid_t)strtoui
145
#error unable to find implementation for strtouid()
148
/* provide strtouid() function alias */
149
#if SIZEOF_GID_T == SIZEOF_UNSIGNED_LONG_INT
150
#define strtogid (gid_t)strtoul
151
#elif SIZEOF_GID_T == SIZEOF_UNSIGNED_LONG_LONG_INT
152
#define strtogid (gid_t)strtoull
153
#elif SIZEOF_GID_T == SIZEOF_UNSIGNED_INT
155
#define WANT_STRTOUI 1
157
#define strtogid (uid_t)strtoui
159
#error unable to find implementation for strtogid()
163
/* provide a strtoui() if it is needed */
164
unsigned int strtoui(const char *nptr,char **endptr,int base);
165
#endif /* WANT_STRTOUI */
97
167
/* these are the functions for initialising the database specific
99
169
void alias_init(void);
140
210
int nslcd_service_all(TFILE *fp,MYLDAP_SESSION *session);
141
211
int nslcd_shadow_byname(TFILE *fp,MYLDAP_SESSION *session);
142
212
int nslcd_shadow_all(TFILE *fp,MYLDAP_SESSION *session);
143
int nslcd_pam_authc(TFILE *fp,MYLDAP_SESSION *session);
213
int nslcd_pam_authc(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid);
144
214
int nslcd_pam_authz(TFILE *fp,MYLDAP_SESSION *session);
145
215
int nslcd_pam_sess_o(TFILE *fp,MYLDAP_SESSION *session);
146
216
int nslcd_pam_sess_c(TFILE *fp,MYLDAP_SESSION *session);
147
int nslcd_pam_pwmod(TFILE *fp,MYLDAP_SESSION *session);
217
int nslcd_pam_pwmod(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid);
149
219
/* macros for generating service handling code */
150
#define NSLCD_HANDLE(db,fn,readfn,logcall,action,mkfilter,writefn) \
220
#define NSLCD_HANDLE(db,fn,readfn,action,mkfilter,writefn) \
151
221
int nslcd_##db##_##fn(TFILE *fp,MYLDAP_SESSION *session) \
152
NSLCD_HANDLE_BODY(db,fn,readfn,logcall,action,mkfilter,writefn)
153
#define NSLCD_HANDLE_UID(db,fn,readfn,logcall,action,mkfilter,writefn) \
222
NSLCD_HANDLE_BODY(db,fn,readfn,action,mkfilter,writefn)
223
#define NSLCD_HANDLE_UID(db,fn,readfn,action,mkfilter,writefn) \
154
224
int nslcd_##db##_##fn(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid) \
155
NSLCD_HANDLE_BODY(db,fn,readfn,logcall,action,mkfilter,writefn)
156
#define NSLCD_HANDLE_BODY(db,fn,readfn,logcall,action,mkfilter,writefn) \
225
NSLCD_HANDLE_BODY(db,fn,readfn,action,mkfilter,writefn)
226
#define NSLCD_HANDLE_BODY(db,fn,readfn,action,mkfilter,writefn) \
158
228
/* define common variables */ \
159
229
int32_t tmpint32; \