FreeBSD Bugzilla – Attachment 13591 Details for
Bug 25787
inetd/auth: -i option to return uid instead of uname
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 4.33 KB, created by
Arne Dag Fidjestøl
on 2001-03-14 03:10:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Arne Dag Fidjestøl
Created:
2001-03-14 03:10:01 UTC
Size:
4.33 KB
patch
obsolete
>Index: builtins.c >=================================================================== >RCS file: /mnt/home/ncvs/src/usr.sbin/inetd/builtins.c,v >retrieving revision 1.19.2.4 >diff -u -r1.19.2.4 builtins.c >--- builtins.c 2001/02/28 12:16:37 1.19.2.4 >+++ builtins.c 2001/03/13 07:33:33 >@@ -345,13 +345,14 @@ > }, to; > struct passwd *pw = NULL; > fd_set fdset; >- char buf[BUFSIZE], *cp = NULL, *p, **av, *osname = NULL, garbage[7], e; >- char *fallback = NULL; >+ char buf[BUFSIZE], *p, **av, *osname = NULL, garbage[7], e; >+ char uidbuf[sizeof "1234567890"]; >+ char *fallback = NULL, *res; > socklen_t socklen; > ssize_t ssize; > size_t size, bufsiz; >- int c, fflag = 0, nflag = 0, rflag = 0, argc = 0, usedfallback = 0; >- int gflag = 0, Fflag = 0, getcredfail = 0, onreadlen; >+ int c, fflag = 0, nflag = 0, rflag = 0, argc = 0; >+ int gflag = 0, Fflag = 0, getcredfail = 0, onreadlen, useuid = 0; > u_short lport, fport; > > inetd_setproctitle(sep->se_service, s); >@@ -373,7 +374,7 @@ > size_t i; > u_int32_t random; > >- while ((c = getopt(argc, sep->se_argv, "d:fFgno:rt:")) != -1) >+ while ((c = getopt(argc, sep->se_argv, "d:fFgino:rt:")) != -1) > switch (c) { > case 'd': > fallback = optarg; >@@ -410,6 +411,9 @@ > } > garbage[i] = '\0'; > break; >+ case 'i': >+ useuid = 1; >+ break; > case 'n': > nflag = 1; > break; >@@ -494,7 +498,7 @@ > if (sscanf(buf, "%hu , %hu%c", &lport, &fport, &e) != 3 || isdigit(e)) > iderror(0, 0, s, 0); > if (gflag) { >- cp = garbage; >+ res = garbage; > goto printit; > } > >@@ -506,10 +510,8 @@ > if (!rflag) { > if (fallback == NULL) > iderror(lport, fport, s, -1); >- else { >- cp = fallback; >- goto printit; >- } >+ res = fallback; >+ goto printit; > } > > /* >@@ -552,19 +554,27 @@ > if (getcredfail != 0) { > if (fallback == NULL) /* Use a default, if asked to */ > iderror(lport, fport, s, getcredfail); >- usedfallback = 1; >- } else { >- /* Look up the pw to get the username */ >- errno = 0; >- pw = getpwuid(uc.cr_uid); >- } >- if (pw == NULL && !usedfallback) /* No such user... */ >+ res = fallback; >+ goto printit; >+ } >+ >+ /* Look up the pw to get the username */ >+ errno = 0; >+ pw = getpwuid(uc.cr_uid); >+ if (pw == NULL) /* No such user... */ > iderror(lport, fport, s, errno != 0 ? errno : ENOENT); >+ >+ if (useuid){ >+ snprintf(uidbuf, sizeof uidbuf, "%u", pw->pw_uid); >+ res = uidbuf; >+ } else >+ res = pw->pw_name; >+ > /* > * If enabled, we check for a file named ".noident" in the user's > * home directory. If found, we return HIDDEN-USER. > */ >- if (nflag && !usedfallback) { >+ if (nflag) { > if (asprintf(&p, "%s/.noident", pw->pw_dir) == -1) > iderror(lport, fport, s, errno); > if (lstat(p, &sb) == 0) { >@@ -578,7 +588,7 @@ > * home directory. It consists of a line containing the name > * they want. > */ >- if (fflag && !usedfallback) { >+ if (fflag) { > FILE *fakeid = NULL; > int fakeid_fd; > >@@ -604,9 +614,9 @@ > if (fakeid_fd != -1 && fstat(fakeid_fd, &sb) != -1 && > S_ISREG(sb.st_mode) && > (fakeid = fdopen(fakeid_fd, "r")) != NULL) { >+ char *cp; > buf[sizeof(buf) - 1] = '\0'; > if (fgets(buf, sizeof(buf), fakeid) == NULL) { >- cp = pw->pw_name; > fclose(fakeid); > goto printit; > } >@@ -626,33 +636,23 @@ > if (strlen(cp) > 16) > cp[16] = '\0'; > /* >- * If the name is a zero-length string or matches >- * the name of another user, it's invalid, so >- * we will return their real identity instead. >+ * If the name is a non-empty string and it >+ * doesn't match the the name of another >+ * user ( unless so permitted by -F option ), >+ * it is used for reply. Otherwise the real >+ * identity is used. > */ >- >- if (!*cp || (!Fflag && getpwnam(cp))) { >- errno = 0; >- pw = getpwuid(uc.cr_uid); >- if (pw == NULL) >- iderror(lport, fport, s, >- errno != 0 ? errno : ENOENT); >- cp = pw->pw_name; >- } >- } else >- cp = pw->pw_name; >- if (fakeid != NULL) >+ if (*cp && (Fflag || !getpwnam(cp))) >+ res = cp; > fclose(fakeid); >- else if (fakeid_fd != -1) >+ } >+ if (fakeid_fd != -1) > close(fakeid_fd); >- } else if (!usedfallback) >- cp = pw->pw_name; >- else >- cp = fallback; >+ } > printit: > /* Finally, we make and send the reply. */ > if (asprintf(&p, "%d , %d : USERID : %s : %s\r\n", lport, fport, osname, >- cp) == -1) { >+ res) == -1) { > syslog(LOG_ERR, "asprintf: %m"); > exit(EX_OSERR); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 25787
: 13591