1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00
2000-05-29  Ulrich Drepper  <drepper@redhat.com>

	* inet/Makefile (CFLAGS-rcmd.c, CFLAGS-rexec.c, CFLAGS-ruserpass.c):
	Removed.
	* inet/rcmd.c: Remove __P.  Remove unused variables.
	(iruserfopen): Make first parameter const.
	(ruserok_sa): Return result of ruserok2_sa.
	(__checkhost_sa): Correctly iterate through results of getaddrinfo.
	* inet/rexec.c: Remove unused variables.  Other small cleanups.
	* inet/ruserpass.c: Remove __P.  Remove unused variables.
	(ruserpass): Check results of memory allocation.
	* include/netdb.h: Add prototype for ruserpass.
This commit is contained in:
Ulrich Drepper
2000-05-29 18:04:55 +00:00
parent 41b5aaf9c9
commit 3846463e07
5 changed files with 66 additions and 44 deletions

View File

@ -1,3 +1,16 @@
2000-05-29 Ulrich Drepper <drepper@redhat.com>
* inet/Makefile (CFLAGS-rcmd.c, CFLAGS-rexec.c, CFLAGS-ruserpass.c):
Removed.
* inet/rcmd.c: Remove __P. Remove unused variables.
(iruserfopen): Make first parameter const.
(ruserok_sa): Return result of ruserok2_sa.
(__checkhost_sa): Correctly iterate through results of getaddrinfo.
* inet/rexec.c: Remove unused variables. Other small cleanups.
* inet/ruserpass.c: Remove __P. Remove unused variables.
(ruserpass): Check results of memory allocation.
* include/netdb.h: Add prototype for ruserpass.
2000-05-29 Jakub Jelinek <jakub@redhat.com> 2000-05-29 Jakub Jelinek <jakub@redhat.com>
* inet/rcmd.c (rresvport_af): Use correct port number. * inet/rcmd.c (rresvport_af): Use correct port number.

View File

@ -77,4 +77,7 @@ extern int __getnetgrent_r (char **__restrict __hostp,
char **__restrict __userp, char **__restrict __userp,
char **__restrict __domainp, char **__restrict __domainp,
char *__restrict __buffer, size_t __buflen); char *__restrict __buffer, size_t __buflen);
extern int ruserpass (const char *host, const char **aname,
const char **apass);
#endif /* !_NETDB_H */ #endif /* !_NETDB_H */

View File

@ -81,9 +81,9 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#include <stdlib.h> #include <stdlib.h>
int __ivaliduser __P ((FILE *, u_int32_t, const char *, const char *)); int __ivaliduser (FILE *, u_int32_t, const char *, const char *);
static int __validuser2_sa __P ((FILE *, struct sockaddr *, size_t, static int __validuser2_sa (FILE *, struct sockaddr *, size_t,
const char *, const char *, const char *)); const char *, const char *, const char *);
static int ruserok2_sa (struct sockaddr *ra, size_t ralen, static int ruserok2_sa (struct sockaddr *ra, size_t ralen,
int superuser, const char *ruser, int superuser, const char *ruser,
const char *luser, const char *rhost); const char *luser, const char *rhost);
@ -106,8 +106,6 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
sa_family_t af; sa_family_t af;
{ {
char paddr[INET6_ADDRSTRLEN]; char paddr[INET6_ADDRSTRLEN];
size_t hstbuflen;
char *tmphstbuf;
struct addrinfo hints, *res, *ai; struct addrinfo hints, *res, *ai;
struct sockaddr_storage from; struct sockaddr_storage from;
struct pollfd pfd[2]; struct pollfd pfd[2];
@ -314,7 +312,7 @@ rresvport_af(alport, family)
struct sockaddr_storage ss; struct sockaddr_storage ss;
int s; int s;
size_t len; size_t len;
uint16_t *sport, i; uint16_t *sport;
switch(family){ switch(family){
case AF_INET: case AF_INET:
@ -401,7 +399,7 @@ ruserok(rhost, superuser, ruser, luser)
/* Extremely paranoid file open function. */ /* Extremely paranoid file open function. */
static FILE * static FILE *
iruserfopen (char *file, uid_t okuser) iruserfopen (const char *file, uid_t okuser)
{ {
struct stat st; struct stat st;
char *cp = NULL; char *cp = NULL;
@ -519,7 +517,7 @@ static int ruserok_sa(ra, ralen, superuser, ruser, luser)
int superuser; int superuser;
const char *ruser, *luser; const char *ruser, *luser;
{ {
ruserok2_sa(ra, ralen, superuser, ruser, luser, "-"); return ruserok2_sa(ra, ralen, superuser, ruser, luser, "-");
} }
/* This is the exported version. */ /* This is the exported version. */
@ -590,19 +588,13 @@ __ivaliduser(hostf, raddr, luser, ruser)
/* Returns 1 on positive match, 0 on no match, -1 on negative match. */ /* Returns 1 on positive match, 0 on no match, -1 on negative match. */
static int static int
internal_function internal_function
__checkhost_sa (ra, ralen, lhost, rhost) __checkhost_sa (struct sockaddr *ra, size_t ralen, char *lhost,
struct sockaddr *ra; const char *rhost)
size_t ralen;
char *lhost;
const char *rhost;
{ {
struct addrinfo hints, *res0, *res; struct addrinfo hints, *res0, *res;
int herr;
int save_errno;
char raddr[INET6_ADDRSTRLEN]; char raddr[INET6_ADDRSTRLEN];
int match; int match;
int negate=1; /* Multiply return with this to get -1 instead of 1 */ int negate=1; /* Multiply return with this to get -1 instead of 1 */
char *user;
/* Check nis netgroup. */ /* Check nis netgroup. */
if (strncmp ("+@", lhost, 2) == 0) if (strncmp ("+@", lhost, 2) == 0)
@ -632,29 +624,29 @@ __checkhost_sa (ra, ralen, lhost, rhost)
hints.ai_family = ra->sa_family; hints.ai_family = ra->sa_family;
if (getaddrinfo(lhost, NULL, &hints, &res0) == 0){ if (getaddrinfo(lhost, NULL, &hints, &res0) == 0){
/* Spin through ip addresses. */ /* Spin through ip addresses. */
for (res=res0; res; res->ai_next){ for (res = res0; res; res = res->ai_next)
if (res->ai_family == ra->sa_family && {
!memcmp(res->ai_addr, ra, res->ai_addrlen)){ if (res->ai_family == ra->sa_family
&& !memcmp(res->ai_addr, ra, res->ai_addrlen))
{
match = 1; match = 1;
break; break;
} }
} }
freeaddrinfo(res0); freeaddrinfo (res0);
} }
return (negate * match); return negate * match;
} }
/* Returns 1 on positive match, 0 on no match, -1 on negative match. */ /* Returns 1 on positive match, 0 on no match, -1 on negative match. */
static int static int
internal_function internal_function
__icheckuser (luser, ruser) __icheckuser (const char *luser, const char *ruser)
const char *luser, *ruser;
{ {
/* /*
luser is user entry from .rhosts/hosts.equiv file luser is user entry from .rhosts/hosts.equiv file
ruser is user id on remote host ruser is user id on remote host
*/ */
char *user;
/* [-+]@netgroup */ /* [-+]@netgroup */
if (strncmp ("+@", luser, 2) == 0) if (strncmp ("+@", luser, 2) == 0)
@ -679,8 +671,7 @@ __icheckuser (luser, ruser)
* Returns 1 for blank lines (or only comment lines) and 0 otherwise * Returns 1 for blank lines (or only comment lines) and 0 otherwise
*/ */
static int static int
__isempty(p) __isempty (char *p)
char *p;
{ {
while (*p && isspace (*p)) { while (*p && isspace (*p)) {
++p; ++p;

View File

@ -40,6 +40,7 @@ static char sccsid[] = "@(#)rexec.c 8.1 (Berkeley) 6/4/93";
#include <stdio.h> #include <stdio.h>
#include <netdb.h> #include <netdb.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -58,11 +59,10 @@ rexec_af(ahost, rport, name, pass, cmd, fd2p, af)
struct addrinfo hints, *res0; struct addrinfo hints, *res0;
const char *orig_name = name; const char *orig_name = name;
const char *orig_pass = pass; const char *orig_pass = pass;
u_short port; u_short port = 0;
int s, timo = 1, s3; int s, timo = 1, s3;
char c; char c;
int herr; int gai;
int gai, ok;
char servbuff[NI_MAXSERV]; char servbuff[NI_MAXSERV];
snprintf(servbuff, sizeof(servbuff), "%d", rport); snprintf(servbuff, sizeof(servbuff), "%d", rport);
@ -72,7 +72,8 @@ rexec_af(ahost, rport, name, pass, cmd, fd2p, af)
hints.ai_family = af; hints.ai_family = af;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME; hints.ai_flags = AI_CANONNAME;
if (gai = getaddrinfo(*ahost, servbuff, &hints, &res0)){ gai = getaddrinfo(*ahost, servbuff, &hints, &res0);
if (gai){
/* XXX: set errno? */ /* XXX: set errno? */
return -1; return -1;
} }
@ -148,9 +149,9 @@ retry:
/* We don't need the memory allocated for the name and the password /* We don't need the memory allocated for the name and the password
in ruserpass anymore. */ in ruserpass anymore. */
if (name != orig_name) if (name != orig_name)
free (name); free ((char *) name);
if (pass != orig_pass) if (pass != orig_pass)
free (pass); free ((char *) pass);
if (__read(s, &c, 1) != 1) { if (__read(s, &c, 1) != 1) {
perror(*ahost); perror(*ahost);

View File

@ -37,6 +37,7 @@ static char sccsid[] = "@(#)ruserpass.c 8.3 (Berkeley) 4/2/94";
#include <ctype.h> #include <ctype.h>
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
#include <netdb.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -45,7 +46,7 @@ static char sccsid[] = "@(#)ruserpass.c 8.3 (Berkeley) 4/2/94";
/* #include "ftp_var.h" */ /* #include "ftp_var.h" */
static int token __P((void)); static int token (void);
static FILE *cfile; static FILE *cfile;
#define DEFAULT 1 #define DEFAULT 1
@ -93,11 +94,11 @@ static const struct toktab {
int int
ruserpass(host, aname, apass) ruserpass(host, aname, apass)
char *host, **aname, **apass; const char *host, **aname, **apass;
{ {
char *hdir, *buf, *tmp; char *hdir, *buf, *tmp;
char myname[1024], *mydomain; char myname[1024], *mydomain;
int t, i, c, usedefault = 0; int t, usedefault = 0;
struct stat stb; struct stat stb;
hdir = __secure_getenv("HOME"); hdir = __secure_getenv("HOME");
@ -157,14 +158,21 @@ next:
while ((t = token()) && t != MACHINE && t != DEFAULT) switch(t) { while ((t = token()) && t != MACHINE && t != DEFAULT) switch(t) {
case LOGIN: case LOGIN:
if (token()) if (token()) {
if (*aname == 0) { if (*aname == 0) {
*aname = malloc((unsigned) strlen(tokval) + 1); char *newp;
(void) strcpy(*aname, tokval); newp = malloc((unsigned) strlen(tokval) + 1);
if (newp == NULL)
{
warnx(_("out of memory"));
goto bad;
}
*aname = strcpy(newp, tokval);
} else { } else {
if (strcmp(*aname, tokval)) if (strcmp(*aname, tokval))
goto next; goto next;
} }
}
break; break;
case PASSWD: case PASSWD:
if (strcmp(*aname, "anonymous") && if (strcmp(*aname, "anonymous") &&
@ -175,8 +183,14 @@ next:
goto bad; goto bad;
} }
if (token() && *apass == 0) { if (token() && *apass == 0) {
*apass = malloc((unsigned) strlen(tokval) + 1); char *newp;
(void) strcpy(*apass, tokval); newp = malloc((unsigned) strlen(tokval) + 1);
if (newp == NULL)
{
warnx(_("out of memory"));
goto bad;
}
*apass = strcpy(newp, tokval);
} }
break; break;
case ACCOUNT: case ACCOUNT: