diff options
author | Jeremy Allison <jra@samba.org> | 1998-04-09 20:48:48 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-04-09 20:48:48 +0000 |
commit | af80d8e98f2f74939d680c6abc21e3f40b927f31 (patch) | |
tree | fdca9c39f0ce5ad080b57edbbfefb1c315539946 /source3/lib | |
parent | 9907a58ca63ec4a8c39709da4a275ddf0b6a3aa3 (diff) | |
download | samba-af80d8e98f2f74939d680c6abc21e3f40b927f31.tar.gz samba-af80d8e98f2f74939d680c6abc21e3f40b927f31.tar.bz2 samba-af80d8e98f2f74939d680c6abc21e3f40b927f31.zip |
Makefile, loadparm.c, server.c, smb.h, util.c: Patch from
stn@techfak.uni-kiel.de (Stefan Nehlsen) to get homes from
the NIS+ map.
smbpasswd.c: Tidy up of cli_state structure.
Jeremy.
(This used to be commit fc2295e0f5729585fdb3ee47edb290851d4071c5)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 3173d52692..484dfe21bd 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -22,8 +22,12 @@ #include "includes.h" #if (defined(NETGROUP) && defined (AUTOMOUNT)) +#ifdef NISPLUS +#include <rpcsvc/nis.h> +#else #include "rpcsvc/ypclnt.h" #endif +#endif pstring scope = ""; @@ -3811,6 +3815,58 @@ char *client_addr(int fd) *******************************************************************/ #if (defined(NETGROUP) && defined(AUTOMOUNT)) +#ifdef NISPLUS +static char *automount_lookup(char *user_name) +{ + static fstring last_key = ""; + static pstring last_value = ""; + + char *nis_map = (char *)lp_nis_home_map_name(); + + char nis_domain[NIS_MAXNAMELEN + 1]; + char buffer[NIS_MAXATTRVAL + 1]; + nis_result *result; + nis_object *object; + entry_obj *entry; + + strncpy(nis_domain, (char *)nis_local_directory(), NIS_MAXNAMELEN); + nis_domain[NIS_MAXNAMELEN] = '\0'; + + DEBUG(5, ("NIS+ Domain: %s\n", nis_domain)); + + if (strcmp(user_name, last_key)) + { + sprintf(buffer, "[%s=%s]%s.%s", "key", user_name, nis_map, nis_domain); + DEBUG(5, ("NIS+ querystring: %s\n", buffer)); + + if (result = nis_list(buffer, RETURN_RESULT, NULL, NULL)) + { + if (result->status != NIS_SUCCESS) + { + DEBUG(3, ("NIS+ query failed: %s\n", nis_sperrno(result->status))); + fstrcpy(last_key, ""); pstrcpy(last_value, ""); + } + else + { + object = result->objects.objects_val; + if (object->zo_data.zo_type == ENTRY_OBJ) + { + entry = &object->zo_data.objdata_u.en_data; + DEBUG(5, ("NIS+ entry type: %s\n", entry->en_type)); + DEBUG(3, ("NIS+ result: %s\n", entry->en_cols.en_cols_val[1].ec_value.ec_value_val)); + + pstrcpy(last_value, entry->en_cols.en_cols_val[1].ec_value.ec_value_val); + string_sub(last_value, "&", user_name); + fstrcpy(last_key, user_name); + } + } + } + nis_freeresult(result); + } + DEBUG(4, ("NIS+ Lookup: %s resulted in %s\n", user_name, last_value)); + return last_value; +} +#else /* NISPLUS */ static char *automount_lookup(char *user_name) { static fstring last_key = ""; @@ -3857,6 +3913,7 @@ static char *automount_lookup(char *user_name) DEBUG(4, ("YP Lookup: %s resulted in %s\n", user_name, last_value)); return last_value; } +#endif /* NISPLUS */ #endif /******************************************************************* |