diff options
Diffstat (limited to 'nis')
-rw-r--r-- | nis/Makefile | 4 | ||||
-rw-r--r-- | nis/libnsl.map | 14 | ||||
-rw-r--r-- | nis/libnss_compat.map | 11 | ||||
-rw-r--r-- | nis/libnss_nis.map | 25 | ||||
-rw-r--r-- | nis/libnss_nisplus.map | 32 | ||||
-rw-r--r-- | nis/nis_add.c | 2 | ||||
-rw-r--r-- | nis/nis_addmember.c | 15 | ||||
-rw-r--r-- | nis/nis_call.c | 18 | ||||
-rw-r--r-- | nis/nis_clone.c | 48 | ||||
-rw-r--r-- | nis/nis_creategroup.c | 4 | ||||
-rw-r--r-- | nis/nis_defaults.c | 10 | ||||
-rw-r--r-- | nis/nis_destroygroup.c | 4 | ||||
-rw-r--r-- | nis/nis_getservlist.c | 11 | ||||
-rw-r--r-- | nis/nis_ismember.c | 17 | ||||
-rw-r--r-- | nis/nis_local_names.c | 73 | ||||
-rw-r--r-- | nis/nis_modify.c | 2 | ||||
-rw-r--r-- | nis/nis_ping.c | 4 | ||||
-rw-r--r-- | nis/nis_print_group_entry.c | 4 | ||||
-rw-r--r-- | nis/nis_remove.c | 2 | ||||
-rw-r--r-- | nis/nis_removemember.c | 29 | ||||
-rw-r--r-- | nis/nis_server.c | 4 | ||||
-rw-r--r-- | nis/nis_table.c | 6 | ||||
-rw-r--r-- | nis/nis_verifygroup.c | 4 | ||||
-rw-r--r-- | nis/nss_nis/nis-hosts.c | 2 | ||||
-rw-r--r-- | nis/nss_nis/nis-netgrp.c | 4 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-hosts.c | 2 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-spwd.c | 98 |
27 files changed, 284 insertions, 165 deletions
diff --git a/nis/Makefile b/nis/Makefile index a6d14d0875..770f3b8283 100644 --- a/nis/Makefile +++ b/nis/Makefile @@ -50,15 +50,19 @@ libnsl-routines = yp_xdr ypclnt ypupdate_xdr \ nis_removemember nis_creategroup nis_destroygroup\ nis_print_group_entry nis_domain_of nis_domain_of_r\ nis_modify nis_remove nis_add nis_defaults +libnsl-map = libnsl.map libnss_compat-routines := $(addprefix compat-,grp pwd spwd) libnss_compat-inhibit-o = $(filter-out .so,$(object-suffixes)) +libnss_compat-map := libnss_compat.map libnss_nis-routines := $(addprefix nis-,$(databases)) libnss_nis-inhibit-o = $(filter-out .so,$(object-suffixes)) +libnss_nis-map := libnss_nis.map libnss_nisplus-routines := $(addprefix nisplus-,$(databases)) libnss_nisplus-inhibit-o = $(filter-out .so,$(object-suffixes)) +libnss_nisplus-map := libnss_nisplus.map include ../Rules diff --git a/nis/libnsl.map b/nis/libnsl.map new file mode 100644 index 0000000000..5cb3bc30f7 --- /dev/null +++ b/nis/libnsl.map @@ -0,0 +1,14 @@ +GLIBC_2.0 { + global: + nis_add; nis_add_entry; nis_addmember; nis_checkpoint; nis_clone_directory; + nis_clone_entry; nis_clone_group; nis_clone_link; nis_clone_nis_attr; + nis_clone_objdata; nis_clone_object; nis_clone_result; nis_clone_table; + nis_creategroup; nis_destroy_object; nis_destroygroup; nis_dir_cmp; + nis_domain_of; nis_domain_of_r; nis_first_entry; nis_free_attr; + nis_free_directory; nis_free_endpoints; nis_free_entry; nis_free_group; + nis_free_link; nis_free_object; nis_free_request; nis_free_servers; + nis_free_table; + + local: + *; +}; \ No newline at end of file diff --git a/nis/libnss_compat.map b/nis/libnss_compat.map new file mode 100644 index 0000000000..55d6f4745f --- /dev/null +++ b/nis/libnss_compat.map @@ -0,0 +1,11 @@ +GLIBC_2.0 { + global: + _nss_compat_endgrent; _nss_compat_endpwent; _nss_compat_endspent; + _nss_compat_getgrent_r; _nss_compat_getgrgid_r; _nss_compat_getgrnam_r; + _nss_compat_getpwent_r; _nss_compat_getpwnam_r; _nss_compat_getpwuid_r; + _nss_compat_getspent_r; _nss_compat_getspnam_r; _nss_compat_setgrent; + _nss_compat_setpwent; _nss_compat_setspent; + + local: + *; +}; \ No newline at end of file diff --git a/nis/libnss_nis.map b/nis/libnss_nis.map new file mode 100644 index 0000000000..2773fca29b --- /dev/null +++ b/nis/libnss_nis.map @@ -0,0 +1,25 @@ +GLIBC_2.0 { + global: + _nss_nis_endaliasent; _nss_nis_endetherent; _nss_nis_endgrent; + _nss_nis_endhostent; _nss_nis_endnetent; _nss_nis_endnetgrent; + _nss_nis_endprotoent; _nss_nis_endpwent; _nss_nis_endrpcent; + _nss_nis_endservent; _nss_nis_endspent; _nss_nis_getaliasbyname_r; + _nss_nis_getaliasent_r; _nss_nis_getetherent_r; _nss_nis_getgrent_r; + _nss_nis_getgrgid_r; _nss_nis_getgrnam_r; _nss_nis_gethostbyaddr_r; + _nss_nis_gethostbyname2_r; _nss_nis_gethostbyname_r; _nss_nis_gethostent_r; + _nss_nis_gethostton_r; _nss_nis_getnetbyaddr_r; _nss_nis_getnetbyname_r; + _nss_nis_getnetent_r; _nss_nis_getnetgrent_r; _nss_nis_getntohost_r; + _nss_nis_getprotobyname_r; _nss_nis_getprotobynumber_r; + _nss_nis_getprotoent_r; _nss_nis_getpublickey; _nss_nis_getpwent_r; + _nss_nis_getpwnam_r; _nss_nis_getpwuid_r; _nss_nis_getrpcbyname_r; + _nss_nis_getrpcbynumber_r; _nss_nis_getrpcent_r; _nss_nis_getsecretkey; + _nss_nis_getservbyname_r; _nss_nis_getservbyport_r; _nss_nis_getservent_r; + _nss_nis_getspent_r; _nss_nis_getspnam_r; _nss_nis_netname2user; + _nss_nis_setaliasent; _nss_nis_setetherent; _nss_nis_setgrent; + _nss_nis_sethostent; _nss_nis_setnetent; _nss_nis_setnetgrent; + _nss_nis_setprotoent; _nss_nis_setpwent; _nss_nis_setrpcent; + _nss_nis_setservent; _nss_nis_setspent; + + local: + *; +}; diff --git a/nis/libnss_nisplus.map b/nis/libnss_nisplus.map new file mode 100644 index 0000000000..b178c02552 --- /dev/null +++ b/nis/libnss_nisplus.map @@ -0,0 +1,32 @@ +GLIBC_2.0 { + global: + _nss_nisplus_endaliasent; _nss_nisplus_endetherent; _nss_nisplus_endgrent; + _nss_nisplus_endhostent; _nss_nisplus_endnetent; _nss_nisplus_endnetgrent; + _nss_nisplus_endprotoent; _nss_nisplus_endpwent; _nss_nisplus_endrpcent; + _nss_nisplus_endservent; _nss_nisplus_endspent; + _nss_nisplus_getaliasbyname_r; _nss_nisplus_getaliasent_r; + _nss_nisplus_getetherent_r; _nss_nisplus_getgrent_r; + _nss_nisplus_getgrgid_r; _nss_nisplus_getgrnam_r; + _nss_nisplus_gethostbyaddr_r; _nss_nisplus_gethostbyname2_r; + _nss_nisplus_gethostbyname_r; _nss_nisplus_gethostent_r; + _nss_nisplus_gethostton_r; _nss_nisplus_getnetbyaddr_r; + _nss_nisplus_getnetbyname_r; _nss_nisplus_getnetent_r; + _nss_nisplus_getnetgrent_r; _nss_nisplus_getntohost_r; + _nss_nisplus_getprotobyname_r; _nss_nisplus_getprotobynumber_r; + _nss_nisplus_getprotoent_r; _nss_nisplus_getpublickey; + _nss_nisplus_getpwent_r; _nss_nisplus_getpwnam_r; _nss_nisplus_getpwuid_r; + _nss_nisplus_getrpcbyname_r; _nss_nisplus_getrpcbynumber_r; + _nss_nisplus_getrpcent_r; _nss_nisplus_getsecretkey; + _nss_nisplus_getservbyname_r; _nss_nisplus_getservbynumber_r; + _nss_nisplus_getservent_r; _nss_nisplus_getspent_r; + _nss_nisplus_getspnam_r; _nss_nisplus_netname2user; + _nss_nisplus_parse_grent; _nss_nisplus_parse_pwent; + _nss_nisplus_parse_spent; _nss_nisplus_setaliasent; + _nss_nisplus_setetherent; _nss_nisplus_setgrent; _nss_nisplus_sethostent; + _nss_nisplus_setnetent; _nss_nisplus_setnetgrent; _nss_nisplus_setprotoent; + _nss_nisplus_setpwent; _nss_nisplus_setrpcent; _nss_nisplus_setservent; + _nss_nisplus_setspent; + + local: + *; +}; diff --git a/nis/nis_add.c b/nis/nis_add.c index 6e11f17ff6..e358ea4987 100644 --- a/nis/nis_add.c +++ b/nis/nis_add.c @@ -41,7 +41,7 @@ nis_add (const_nis_name name, const nis_object *obj) p1 = req.ns_object.ns_object_val[0].zo_name; req.ns_object.ns_object_val[0].zo_name = - nis_name_of_r (name, buf1, sizeof (buf1)); + nis_leaf_of_r (name, buf1, sizeof (buf1)); p2 = req.ns_object.ns_object_val[0].zo_owner; if (p2 == NULL || strlen (p2) == 0) diff --git a/nis/nis_addmember.c b/nis/nis_addmember.c index 2eee9cc8bf..8fd7e12a58 100644 --- a/nis/nis_addmember.c +++ b/nis/nis_addmember.c @@ -26,7 +26,7 @@ nis_addmember (const_nis_name member, const_nis_name group) { if (group != NULL && strlen (group) > 0) { - char buf[strlen (group) + 50]; + char buf[strlen (group) + 14 + NIS_MAXNAMELEN]; char leafbuf[strlen (group) + 2]; char domainbuf[strlen (group) + 2]; nis_result *res, *res2; @@ -38,8 +38,8 @@ nis_addmember (const_nis_name member, const_nis_name group) cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); if (cp2 != NULL && strlen (cp2) > 0) { - cp = stpcpy (cp, "."); - strcpy (cp, cp2); + *cp++ = '.'; + stpcpy (cp, cp2); } res = nis_lookup (buf, FOLLOW_LINKS|EXPAND_NAME); if (res->status != NIS_SUCCESS) @@ -53,10 +53,15 @@ nis_addmember (const_nis_name member, const_nis_name group) return NIS_INVALIDOBJ; res->objects.objects_val[0].GR_data.gr_members.gr_members_val - = realloc (res->objects.objects_val[0].GR_data.gr_members.gr_members_val, res->objects.objects_val[0].GR_data.gr_members.gr_members_len + 1); - ++res->objects.objects_val[0].GR_data.gr_members.gr_members_len; + = realloc (res->objects.objects_val[0].GR_data.gr_members.gr_members_val, + (res->objects.objects_val[0].GR_data.gr_members.gr_members_len + 1) + * sizeof (char *)); res->objects.objects_val[0].GR_data.gr_members.gr_members_val[res->objects.objects_val[0].GR_data.gr_members.gr_members_len] = strdup (member); + ++res->objects.objects_val[0].GR_data.gr_members.gr_members_len; + cp = stpcpy (buf, res->objects.objects_val->zo_name); + *cp++ = '.'; + strncpy (cp, res->objects.objects_val->zo_domain, NIS_MAXNAMELEN); res2 = nis_modify (buf, res->objects.objects_val); status = res2->status; nis_freeresult (res); diff --git a/nis/nis_call.c b/nis/nis_call.c index 17f67abbde..08a20acd73 100644 --- a/nis/nis_call.c +++ b/nis/nis_call.c @@ -65,12 +65,12 @@ __nis_dobind (const nis_server *server, u_long flags) clnt_saddr.sin_family = AF_INET; for (i = 0; i < server->ep.ep_len; i++) { - if (strcmp (server->ep.ep_val[i].family,"loopback") == 0) + if (strcmp (server->ep.ep_val[i].family, "loopback") == 0) { if (server->ep.ep_val[i].uaddr[i] == '-') clnt_saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); else - if (strcmp (server->ep.ep_val[i].proto,"udp") == 0) + if (strcmp (server->ep.ep_val[i].proto, "udp") == 0) { if ((flags & USE_DGRAM) == USE_DGRAM) clnt_saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); @@ -78,7 +78,7 @@ __nis_dobind (const nis_server *server, u_long flags) continue; } else - if (strcmp (server->ep.ep_val[i].proto,"tcp") == 0) + if (strcmp (server->ep.ep_val[i].proto, "tcp") == 0) { if ((flags & USE_DGRAM) == USE_DGRAM) continue; @@ -87,13 +87,13 @@ __nis_dobind (const nis_server *server, u_long flags) } } else - if (strcmp (server->ep.ep_val[i].family,"inet") == 0) + if (strcmp (server->ep.ep_val[i].family, "inet") == 0) { if (server->ep.ep_val[i].uaddr[i] == '-') clnt_saddr.sin_addr.s_addr = inetstr2int (server->ep.ep_val[i].uaddr); else - if (strcmp (server->ep.ep_val[i].proto,"udp") == 0) + if (strcmp (server->ep.ep_val[i].proto, "udp") == 0) { if ((flags & USE_DGRAM) == USE_DGRAM) clnt_saddr.sin_addr.s_addr = @@ -102,7 +102,7 @@ __nis_dobind (const nis_server *server, u_long flags) continue; } else - if (strcmp (server->ep.ep_val[i].proto,"tcp") == 0) + if (strcmp (server->ep.ep_val[i].proto, "tcp") == 0) { if ((flags & USE_DGRAM) == USE_DGRAM) continue; @@ -310,6 +310,7 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, u_long flags) char leaf [strlen (name) + 3]; char ndomain [strlen (name) + 3]; u_int i; + char *cp; do { @@ -323,8 +324,9 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, u_long flags) strcpy (domain, ndomain); } while (nis_dir_cmp (domain, dir->do_name) != SAME_NAME); - strcat (leaf, "."); - strcat (leaf, domain); + cp = strchr (leaf, '\0'); + *cp++ = '.'; + strcpy (cp, domain); for (i = 0; i < dir->do_servers.do_servers_len; ++i) { diff --git a/nis/nis_clone.c b/nis/nis_clone.c index 860abb386c..e4dc87d4c9 100644 --- a/nis/nis_clone.c +++ b/nis/nis_clone.c @@ -264,7 +264,7 @@ nis_clone_entry (const entry_obj *src, entry_obj *dest) if (res->en_cols.en_cols_val == NULL && src->en_cols.en_cols_len > 0) { res->en_cols.en_cols_val = - malloc (src->en_cols.en_cols_len * sizeof (entry_col)); + calloc (1, src->en_cols.en_cols_len * sizeof (entry_col)); if (res->en_cols.en_cols_val == NULL) return NULL; } @@ -374,8 +374,13 @@ nis_clone_link (const link_obj *src, link_obj *dest) res->li_attrs.li_attrs_val, src->li_attrs.li_attrs_len); - if ((res->li_name = strdup (src->li_name)) == NULL) - return NULL; + if (src->li_name) + { + if ((res->li_name = strdup (src->li_name)) == NULL) + return NULL; + } + else + res->li_name = NULL; return res; } @@ -477,15 +482,34 @@ nis_clone_object (const nis_object *src, nis_object *dest) res->zo_oid = src->zo_oid; - if ((res->zo_name = strdup (src->zo_name)) == NULL) - return NULL; - if ((res->zo_owner = strdup (src->zo_owner)) == NULL) - return NULL; - if ((res->zo_group = strdup (src->zo_group)) == NULL) - return NULL; - if ((res->zo_domain = strdup (src->zo_domain)) == NULL) - return NULL; - + if (src->zo_name) + { + if ((res->zo_name = strdup (src->zo_name)) == NULL) + return NULL; + } + else + res->zo_name = NULL; + if (src->zo_owner) + { + if ((res->zo_owner = strdup (src->zo_owner)) == NULL) + return NULL; + } + else + res->zo_owner = NULL; + if (src->zo_group) + { + if ((res->zo_group = strdup (src->zo_group)) == NULL) + return NULL; + } + else + res->zo_group = NULL; + if (src->zo_domain) + { + if ((res->zo_domain = strdup (src->zo_domain)) == NULL) + return NULL; + } + else + res->zo_domain = NULL; res->zo_access = src->zo_access; res->zo_ttl = src->zo_ttl; diff --git a/nis/nis_creategroup.c b/nis/nis_creategroup.c index c62b039b5e..d1de08c08d 100644 --- a/nis/nis_creategroup.c +++ b/nis/nis_creategroup.c @@ -39,8 +39,8 @@ nis_creategroup (const_nis_name group, u_long flags) cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); if (cp2 != NULL && strlen (cp2) > 0) { - cp = stpcpy (cp, "."); - strcpy (cp, cp2); + *cp++ = '.'; + stpcpy (cp, cp2); } else return NIS_BADNAME; diff --git a/nis/nis_defaults.c b/nis/nis_defaults.c index 9d152d1f11..53a585b516 100644 --- a/nis/nis_defaults.c +++ b/nis/nis_defaults.c @@ -46,11 +46,9 @@ searchgroup (char *str) while (cptr[i] != '\0' && cptr[i] != ':') i++; if (i == 0) /* only "group=" ? */ - return (nis_name)""; - - strncpy (default_group, cptr, i); + return (nis_name) ""; - return default_group; + return strncpy (default_group, cptr, i); } static nis_name @@ -71,9 +69,7 @@ searchowner (char *str) if (i == 0) /* only "owner=" ? */ return (nis_name)""; - strncpy (default_owner, cptr, i); - - return default_owner; + return strncpy (default_owner, cptr, i); } static u_long diff --git a/nis/nis_destroygroup.c b/nis/nis_destroygroup.c index 524e0776ac..6ece45345d 100644 --- a/nis/nis_destroygroup.c +++ b/nis/nis_destroygroup.c @@ -38,8 +38,8 @@ nis_destroygroup (const_nis_name group) cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); if (cp2 != NULL && strlen (cp2) > 0) { - cp = stpcpy (cp, "."); - strcpy (cp, cp2); + *cp++ = '.'; + stpcpy (cp, cp2); } res = nis_remove (buf, NULL); status = res->status; diff --git a/nis/nis_getservlist.c b/nis/nis_getservlist.c index 0c9fbfb60d..b30b70b584 100644 --- a/nis/nis_getservlist.c +++ b/nis/nis_getservlist.c @@ -35,7 +35,7 @@ nis_getservlist (const_nis_name dir) unsigned long i; nis_server *server; - serv = malloc (sizeof (nis_server *) * + serv = calloc (1, sizeof (nis_server *) * (res->objects.objects_val->DI_data.do_servers.do_servers_len + 1)); if (serv == NULL) return NULL; @@ -43,10 +43,9 @@ nis_getservlist (const_nis_name dir) { server = &res->objects.objects_val->DI_data.do_servers.do_servers_val[i]; + serv[i] = calloc (1, sizeof (nis_server)); if (server->name != NULL) serv[i]->name = strdup (server->name); - else - serv[i]->name = NULL; serv[i]->ep.ep_len = server->ep.ep_len; if (serv[i]->ep.ep_len > 0) @@ -110,6 +109,10 @@ nis_freeservlist (nis_server **serv) i = 0; while (serv[i] != NULL) - nis_free_servers (serv[i], 1); + { + nis_free_servers (serv[i], 1); + free (serv[i]); + ++i; + } free (serv); } diff --git a/nis/nis_ismember.c b/nis/nis_ismember.c index f0d087ca51..85c401531e 100644 --- a/nis/nis_ismember.c +++ b/nis/nis_ismember.c @@ -42,7 +42,7 @@ internal_ismember (const_nis_name principal, const_nis_name group) cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); if (cp2 != NULL && strlen (cp2) > 0) { - cp = stpcpy (cp, "."); + *cp++ = '.'; strcpy (cp, cp2); } res = nis_lookup (buf, EXPAND_NAME|FOLLOW_LINKS); @@ -112,9 +112,8 @@ internal_ismember (const_nis_name principal, const_nis_name group) char buf1[strlen (principal) + 2]; char buf2[strlen (cp) + 2]; - strcpy (buf1, nis_domain_of (principal)); - strcpy (buf2, nis_domain_of (cp)); - if (strcmp (buf1, buf2) == 0) + if (strcmp (nis_domain_of_r (principal, buf1, sizeof buf1), + nis_domain_of_r (cp, buf2, sizeof buf2)) == 0) return 1; } } @@ -128,15 +127,7 @@ bool_t nis_ismember (const_nis_name principal, const_nis_name group) { if (group != NULL && strlen (group) > 0) - { - int status; - - status = internal_ismember (principal, group); - if (status == 1) - return TRUE; - else - return FALSE; - } + return internal_ismember (principal, group) == 1 ? TRUE : FALSE; else return FALSE; } diff --git a/nis/nis_local_names.c b/nis/nis_local_names.c index e760f433b2..348c7534a3 100644 --- a/nis/nis_local_names.c +++ b/nis/nis_local_names.c @@ -31,6 +31,7 @@ nis_local_group (void) if (__nisgroup[0] == '\0') { char *cptr; + char *cp; if ((cptr = getenv ("NIS_GROUP")) == NULL) return __nisgroup; @@ -38,21 +39,18 @@ nis_local_group (void) if (strlen (cptr) >= NIS_MAXNAMELEN) return __nisgroup; - strcpy (__nisgroup, cptr); + cp = stpcpy (__nisgroup, cptr); - if (__nisgroup[strlen (__nisgroup) - 1] != '.') + if (cp[-1] != '.') { cptr = nis_local_directory (); - if (strlen (__nisgroup) + strlen (cptr) + 1 < NIS_MAXNAMELEN) + if ((cp - __nisgroup) + strlen (cptr) + 1 < NIS_MAXNAMELEN) { - strcat (__nisgroup, "."); - strcat (__nisgroup, cptr); + *cp++ = '.'; + strcpy (cp, cptr); } else - { - __nisgroup[0] = '\0'; - return __nisgroup; - } + __nisgroup[0] = '\0'; } } @@ -64,21 +62,20 @@ nis_name nis_local_directory (void) { static char __nisdomainname[NIS_MAXNAMELEN + 1]; - int len; if (__nisdomainname[0] == '\0') { if (getdomainname (__nisdomainname, NIS_MAXNAMELEN) < 0) - strcpy (__nisdomainname, "\0"); + __nisdomainname[0] = '\0'; else { - len = strlen (__nisdomainname); + char *cp = strchr (__nisdomainname, '\0'); /* Missing trailing dot? */ - if (__nisdomainname[len - 1] != '.') + if (cp[-1] != '.') { - __nisdomainname[len] = '.'; - __nisdomainname[len + 1] = '\0'; + *cp++ = '.'; + *cp = '\0'; } } } @@ -99,28 +96,32 @@ nis_local_principal (void) if (uid != 0) { - snprintf (buf, NIS_MAXNAMELEN - 1, - "[auth_name=%d,auth_type=LOCAL],cred.org_dir.%s", - uid, nis_local_directory ()); + int len = snprintf (buf, NIS_MAXNAMELEN - 1, + "[auth_name=%d,auth_type=LOCAL],cred.org_dir.%s", + uid, nis_local_directory ()); + + if (len >= NIS_MAXNAMELEN - 1) + /* XXX The buffer is too small. Can this happen??? */ + return strcpy (__principal, "nobody"); - if (buf[strlen (buf) - 1] != '.') - strcat (buf, "."); + if (buf[len - 1] != '.') + { + buf[len++] = '.'; + buf[len] = '\0'; + } res = nis_list (buf, USE_DGRAM + NO_AUTHINFO + FOLLOW_LINKS + FOLLOW_PATH, NULL, NULL); if (res == NULL) - { - strcpy (__principal, "nobody"); - return __principal; - } + return strcpy (__principal, "nobody"); if (res->status == NIS_SUCCESS) { if (res->objects.objects_len > 1) { /* More than one principal with same uid? something - wrong with cred table. Should be unique Warn user + wrong with cred table. Should be unique. Warn user and continue. */ printf (_("\ LOCAL entry for UID %d in directory %s not unique\n"), @@ -133,19 +134,14 @@ LOCAL entry for UID %d in directory %s not unique\n"), else { nis_freeresult (res); - strcpy (__principal, "nobody"); - return __principal; + return strcpy (__principal, "nobody"); } } else - { - strcpy (__principal, nis_local_host ()); - return __principal; - } + return strcpy (__principal, nis_local_host ()); /* Should be never reached */ - strcpy (__principal, "nobody"); - return __principal; + return strcpy (__principal, "nobody"); } return __principal; } @@ -154,7 +150,6 @@ nis_name nis_local_host (void) { static char __nishostname[NIS_MAXNAMELEN + 1]; - int len; if (__nishostname[0] == '\0') { @@ -162,21 +157,19 @@ nis_local_host (void) __nishostname[0] = '\0'; else { - char *cp; - len = strlen(__nishostname); + char *cp = strchr (__nishostname, '\0'); + int len = cp - __nishostname; /* Hostname already fully qualified? */ - if (__nishostname[len - 1] == '.') + if (cp[-1] == '.') return __nishostname; - if ((strlen (__nishostname) + strlen (nis_local_directory ()) + 1) > - NIS_MAXNAMELEN) + if (len + strlen (nis_local_directory ()) + 1 > NIS_MAXNAMELEN) { __nishostname[0] = '\0'; return __nishostname; } - cp = &__nishostname[len]; *cp++ = '.'; strncpy (cp, nis_local_directory (), NIS_MAXNAMELEN - len -1); __nishostname[NIS_MAXNAMELEN] = '\0'; diff --git a/nis/nis_modify.c b/nis/nis_modify.c index 9c5aad7913..e68bf2a954 100644 --- a/nis/nis_modify.c +++ b/nis/nis_modify.c @@ -31,7 +31,7 @@ nis_modify (const_nis_name name, const nis_object *obj) res = calloc (1, sizeof (nis_result)); - req.ns_name = (char *)name; + req.ns_name = (char *) name; req.ns_object.ns_object_len = 1; req.ns_object.ns_object_val = nis_clone_object (obj, NULL); diff --git a/nis/nis_ping.c b/nis/nis_ping.c index 610cf03ea5..941adfbda4 100644 --- a/nis/nis_ping.c +++ b/nis/nis_ping.c @@ -40,7 +40,7 @@ nis_ping (const_nis_name dirname, u_long utime, const nis_object *dirobj) obj = res->objects.objects_val; } else - obj = (nis_object *)dirobj; + obj = (nis_object *) dirobj; /* Check if obj is really a diryectory object */ if (obj->zo_data.zo_type != DIRECTORY_OBJ) @@ -49,7 +49,7 @@ nis_ping (const_nis_name dirname, u_long utime, const nis_object *dirobj) if (dirname == NULL) args.dir = obj->DI_data.do_name; else - args.dir = (char *)dirname; + args.dir = (char *) dirname; args.stamp = utime; for (i = 0; i < obj->DI_data.do_servers.do_servers_len; ++i) diff --git a/nis/nis_print_group_entry.c b/nis/nis_print_group_entry.c index e7c866cbe2..1063ef8411 100644 --- a/nis/nis_print_group_entry.c +++ b/nis/nis_print_group_entry.c @@ -38,8 +38,8 @@ nis_print_group_entry (const_nis_name group) cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); if (cp2 != NULL && strlen (cp2) > 0) { - cp = stpcpy (cp, "."); - strcpy (cp, cp2); + *cp++ = '.'; + stpcpy (cp, cp2); } res = nis_lookup (buf, FOLLOW_LINKS|EXPAND_NAME); diff --git a/nis/nis_remove.c b/nis/nis_remove.c index 3ffd66dfe0..e6aed00393 100644 --- a/nis/nis_remove.c +++ b/nis/nis_remove.c @@ -31,7 +31,7 @@ nis_remove (const_nis_name name, const nis_object *obj) res = calloc (1, sizeof (nis_result)); - req.ns_name = (char *)name; + req.ns_name = (char *) name; if (obj != NULL) { diff --git a/nis/nis_removemember.c b/nis/nis_removemember.c index 473438ba5c..8ed67caf98 100644 --- a/nis/nis_removemember.c +++ b/nis/nis_removemember.c @@ -26,14 +26,14 @@ nis_removemember (const_nis_name member, const_nis_name group) { if (group != NULL && strlen (group) > 0) { - char buf[strlen (group) + 50]; + char buf[strlen (group) + 14 + NIS_MAXNAMELEN]; char leafbuf[strlen (group) + 2]; char domainbuf[strlen (group) + 2]; nis_name *newmem; nis_result *res, *res2; nis_error status; char *cp, *cp2; - u_int i, j; + unsigned long int i, j, k; cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1)); cp = stpcpy (cp, ".groups_dir"); @@ -41,7 +41,7 @@ nis_removemember (const_nis_name member, const_nis_name group) if (cp2 != NULL && strlen (cp2) > 0) { cp = stpcpy (cp, "."); - strcpy (cp, cp2); + stpcpy (cp, cp2); } res = nis_lookup (buf, FOLLOW_LINKS|EXPAND_NAME); if (res->status != NIS_SUCCESS) @@ -54,20 +54,35 @@ nis_removemember (const_nis_name member, const_nis_name group) (res->objects.objects_val[0].zo_data.zo_type != GROUP_OBJ)) return NIS_INVALIDOBJ; - newmem = malloc (res->objects.objects_val[0].GR_data.gr_members.gr_members_len); + newmem = calloc (1, res->objects.objects_val[0].GR_data.gr_members.gr_members_len * + sizeof (char *)); + + k = res->objects.objects_val[0].GR_data.gr_members.gr_members_len; j = 0; - for (i = 0; i < res->objects.objects_val[0].GR_data.gr_members.gr_members_len - 1; ++i) + for (i = 0; i < res->objects.objects_val[0].GR_data.gr_members.gr_members_len; + ++i) { - if (strcmp (res->objects.objects_val[0].GR_data.gr_members.gr_members_val[j], member) != 0) + if (strcmp (res->objects.objects_val[0].GR_data.gr_members.gr_members_val[i], + member) != 0) { newmem[j] = res->objects.objects_val[0].GR_data.gr_members.gr_members_val[i]; ++j; } + else + { + free (res->objects.objects_val[0].GR_data.gr_members.gr_members_val[i]); + --k; + } } - --res->objects.objects_val[0].GR_data.gr_members.gr_members_len; free (res->objects.objects_val[0].GR_data.gr_members.gr_members_val); + newmem = realloc (newmem, k * sizeof (char*)); res->objects.objects_val[0].GR_data.gr_members.gr_members_val = newmem; + res->objects.objects_val[0].GR_data.gr_members.gr_members_len = k; + + cp = stpcpy (buf, res->objects.objects_val->zo_name); + *cp++ = '.'; + strncpy (cp, res->objects.objects_val->zo_domain, NIS_MAXNAMELEN); res2 = nis_modify (buf, res->objects.objects_val); status = res2->status; nis_freeresult (res); diff --git a/nis/nis_server.c b/nis/nis_server.c index 4d6b1c1100..5274a3bfc4 100644 --- a/nis/nis_server.c +++ b/nis/nis_server.c @@ -33,7 +33,7 @@ nis_servstate (const nis_server *serv, const nis_tag *tags, tagres.tags.tags_val = NULL; *result = NULL; taglist.tags.tags_len = numtags; - taglist.tags.tags_val = (nis_tag *)tags; + taglist.tags.tags_val = (nis_tag *) tags; if (serv == NULL) { @@ -80,7 +80,7 @@ nis_stats (const nis_server *serv, const nis_tag *tags, tagres.tags.tags_val = NULL; *result = NULL; taglist.tags.tags_len = numtags; - taglist.tags.tags_val = (nis_tag *)tags; + taglist.tags.tags_val = (nis_tag *) tags; if (serv == NULL) { diff --git a/nis/nis_table.c b/nis/nis_table.c index 5fa3c89e0b..e9e35abf3b 100644 --- a/nis/nis_table.c +++ b/nis/nis_table.c @@ -78,7 +78,7 @@ splitname (const_nis_name name, nis_name *ibr_name, int *srch_len, if (!val) { free (cptr); - *srch_val = malloc (sizeof (char *)); + *srch_val = malloc (sizeof (nis_attr)); if (*srch_val == NULL) { free (cptr); @@ -86,8 +86,8 @@ splitname (const_nis_name name, nis_name *ibr_name, int *srch_len, *ibr_name = NULL; return; } - (*srch_val)[*srch_len].zattr_val.zattr_val_len = 0; - (*srch_val)[*srch_len].zattr_val.zattr_val_val = NULL; + (*srch_val)[0].zattr_val.zattr_val_len = 0; + (*srch_val)[0].zattr_val.zattr_val_val = NULL; return; } diff --git a/nis/nis_verifygroup.c b/nis/nis_verifygroup.c index e57f16589a..6a8ab01bd7 100644 --- a/nis/nis_verifygroup.c +++ b/nis/nis_verifygroup.c @@ -38,8 +38,8 @@ nis_verifygroup (const_nis_name group) cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1); if (cp2 != NULL && strlen (cp2) > 0) { - cp = stpcpy (cp, "."); - strcpy (cp, cp2); + *cp++ = '.'; + stpcpy (cp, cp2); } res = nis_lookup (buf, 0); status = res->status; diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c index 91d30c8149..5823c71a80 100644 --- a/nis/nss_nis/nis-hosts.c +++ b/nis/nss_nis/nis-hosts.c @@ -55,7 +55,7 @@ LINE_PARSER STRING_FIELD (addr, isspace, 1); /* Parse address. */ - if (inet_pton (AF_INET6, p, entdata->host_addr) > 0) + if (inet_pton (AF_INET6, addr, entdata->host_addr) > 0) { result->h_addrtype = AF_INET6; result->h_length = IN6ADDRSZ; diff --git a/nis/nss_nis/nis-netgrp.c b/nis/nss_nis/nis-netgrp.c index 7609ea08ed..aa51c2f0df 100644 --- a/nis/nss_nis/nis-netgrp.c +++ b/nis/nss_nis/nis-netgrp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996. @@ -52,7 +52,7 @@ _nss_nis_setnetgrent (char *group) status = NSS_STATUS_SUCCESS; - if (group[0] == '\0') + if (group == NULL || group[0] == '\0') return NSS_STATUS_UNAVAIL; if (yp_get_default_domain (&domain)) diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c index 0a005406d1..e6d584dac8 100644 --- a/nis/nss_nisplus/nisplus-hosts.c +++ b/nis/nss_nisplus/nisplus-hosts.c @@ -66,7 +66,7 @@ LINE_PARSER STRING_FIELD (addr, isspace, 1); /* Parse address. */ - if (inet_pton (AF_INET6, p, entdata->host_addr) > 0) + if (inet_pton (AF_INET6, addr, entdata->host_addr) > 0) { result->h_addrtype = AF_INET6; result->h_length = IN6ADDRSZ; diff --git a/nis/nss_nisplus/nisplus-spwd.c b/nis/nss_nisplus/nisplus-spwd.c index d426d28684..568a1c4006 100644 --- a/nis/nss_nisplus/nisplus-spwd.c +++ b/nis/nss_nisplus/nisplus-spwd.c @@ -44,7 +44,6 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, { char *first_unused = buffer; size_t room_left = buflen; - char *line, *cp; if (result == NULL) return 0; @@ -85,52 +84,57 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, sp->sp_lstchg = sp->sp_min = sp->sp_max = sp->sp_warn = sp->sp_inact = sp->sp_expire = sp->sp_flag = -1; - line = NISENTRYVAL (0, 7, result); - cp = strchr (line, ':'); - if (cp == NULL) - return 0; - *cp++ = '\0'; - sp->sp_lstchg = atol (line); - - line = cp; - cp = strchr (line, ':'); - if (cp == NULL) - return 0; - *cp++ = '\0'; - sp->sp_min = atol(line); - - line = cp; - cp = strchr (line, ':'); - if (cp == NULL) - return 0; - *cp++ = '\0'; - sp->sp_max = atol(line); - - line = cp; - cp = strchr (line, ':'); - if (cp == NULL) - return 0; - *cp++ = '\0'; - sp->sp_warn = atol(line); - - line = cp; - cp = strchr (line, ':'); - if (cp == NULL) - return 0; - *cp++ = '\0'; - sp->sp_inact = atol(line); - - line = cp; - cp = strchr (line, ':'); - if (cp == NULL) - return 0; - *cp++ = '\0'; - sp->sp_expire = atol(line); - - line = cp; - if (line == NULL) - return 0; - sp->sp_flag = atol(line); + if (NISENTRYVAL (0, 7, result) > 0) + { + char *line, *cp; + + line = NISENTRYVAL (0, 7, result); + cp = strchr (line, ':'); + if (cp == NULL) + return 0; + *cp++ = '\0'; + sp->sp_lstchg = atol (line); + + line = cp; + cp = strchr (line, ':'); + if (cp == NULL) + return 0; + *cp++ = '\0'; + sp->sp_min = atol(line); + + line = cp; + cp = strchr (line, ':'); + if (cp == NULL) + return 0; + *cp++ = '\0'; + sp->sp_max = atol(line); + + line = cp; + cp = strchr (line, ':'); + if (cp == NULL) + return 0; + *cp++ = '\0'; + sp->sp_warn = atol(line); + + line = cp; + cp = strchr (line, ':'); + if (cp == NULL) + return 0; + *cp++ = '\0'; + sp->sp_inact = atol(line); + + line = cp; + cp = strchr (line, ':'); + if (cp == NULL) + return 0; + *cp++ = '\0'; + sp->sp_expire = atol(line); + + line = cp; + if (line == NULL) + return 0; + sp->sp_flag = atol(line); + } return 1; } |