diff options
-rw-r--r-- | ChangeLog.txt | 9 | ||||
-rw-r--r-- | guts/README | 2 | ||||
-rw-r--r-- | guts/getgrent_r.c | 8 | ||||
-rw-r--r-- | guts/getgrgid_r.c | 1 | ||||
-rw-r--r-- | guts/getgrnam_r.c | 4 | ||||
-rw-r--r-- | guts/getpwent_r.c | 4 | ||||
-rw-r--r-- | guts/getpwnam_r.c | 4 | ||||
-rw-r--r-- | guts/getpwuid_r.c | 4 | ||||
-rw-r--r-- | guts/mkdtemp.c | 3 | ||||
-rw-r--r-- | guts/mktemp.c | 1 | ||||
-rw-r--r-- | guts/readlinkat.c | 8 | ||||
-rw-r--r-- | pseudo_client.c | 4 | ||||
-rw-r--r-- | pseudo_server.c | 2 | ||||
-rw-r--r-- | pseudo_util.c | 12 | ||||
-rw-r--r-- | wrapfuncs.in | 2 | ||||
-rw-r--r-- | wrapfuncs64.in | 2 |
16 files changed, 59 insertions, 11 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index 0154454..4b76be8 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,12 @@ +2010-04-19: + * (seebs) fix crash if xstat() or similar routine called with null path + * (seebs) fix list of client processes still running + +2010-04-16: + * (seebs) add tracking of program names + * (seebs) track message types + * (seebs) small bug fixes and improvements galore + 2010-04-06: * (seebs) implement various passwd-related utilities, various bugfixes. diff --git a/guts/README b/guts/README index efb6e4b..871e6bb 100644 --- a/guts/README +++ b/guts/README @@ -185,9 +185,11 @@ is set, or else the system /etc/* files. getpwnam_r getpwuid getpwuid_r + lckpwdf setgrent setgroups setpwent + ulckpwdf The implementation of getgroups() is inauthentic in that it always checks the group file when called, rather than checking the group file once diff --git a/guts/getgrent_r.c b/guts/getgrent_r.c index a080f14..b02466a 100644 --- a/guts/getgrent_r.c +++ b/guts/getgrent_r.c @@ -10,12 +10,16 @@ /* note that we don't wrap fgetgrent_r, since there's no path * references in it. */ + if (!pseudo_grp) { + errno = ENOENT; + return -1; + } rc = fgetgrent_r(pseudo_grp, gbuf, buf, buflen, gbufp); if (rc == 0 && *gbufp) { if (*gbufp == gbuf) { - pseudo_debug(1, "found group: %d/%s\n", gbuf->gr_gid, gbuf->gr_name); + pseudo_debug(3, "found group: %d/%s\n", gbuf->gr_gid, gbuf->gr_name); } else { - pseudo_debug(1, "found group, but it's wrong?"); + pseudo_debug(1, "found group (%d), but it's wrong?", gbuf->gr_gid); } } diff --git a/guts/getgrgid_r.c b/guts/getgrgid_r.c index fcaed89..06a91c9 100644 --- a/guts/getgrgid_r.c +++ b/guts/getgrgid_r.c @@ -13,6 +13,7 @@ if (gbuf->gr_gid == gid) { pseudo_debug(1, "found group gid %d, name %s\n", gbuf->gr_gid, gbuf->gr_name); + endgrent(); return rc; } } diff --git a/guts/getgrnam_r.c b/guts/getgrnam_r.c index 73c1c45..39de641 100644 --- a/guts/getgrnam_r.c +++ b/guts/getgrnam_r.c @@ -10,8 +10,10 @@ setgrent(); while ((rc = wrap_getgrent_r(gbuf, buf, buflen, gbufp)) == 0) { /* 0 means no error occurred, and *gbufp == gbuf */ - if (gbuf->gr_name && !strcmp(gbuf->gr_name, name)) + if (gbuf->gr_name && !strcmp(gbuf->gr_name, name)) { + endgrent(); return rc; + } } endgrent(); /* we never found a match; rc is 0 if there was no error, or diff --git a/guts/getpwent_r.c b/guts/getpwent_r.c index aadd97b..d55763e 100644 --- a/guts/getpwent_r.c +++ b/guts/getpwent_r.c @@ -10,6 +10,10 @@ /* note that we don't wrap fgetpwent_r, since there's no path * references in it. */ + if (!pseudo_pwd) { + errno = ENOENT; + return -1; + } return fgetpwent_r(pseudo_pwd, pwbuf, buf, buflen, pwbufp); /* return rc; diff --git a/guts/getpwnam_r.c b/guts/getpwnam_r.c index 1a870f2..5d7a4ea 100644 --- a/guts/getpwnam_r.c +++ b/guts/getpwnam_r.c @@ -10,8 +10,10 @@ setpwent(); while ((rc = wrap_getpwent_r(pwbuf, buf, buflen, pwbufp)) == 0) { /* 0 means no error occurred, and *pwbufp == pwbuf */ - if (pwbuf->pw_name && !strcmp(pwbuf->pw_name, name)) + if (pwbuf->pw_name && !strcmp(pwbuf->pw_name, name)) { + endpwent(); return rc; + } } endpwent(); /* we never found a match; rc is 0 if there was no error, or diff --git a/guts/getpwuid_r.c b/guts/getpwuid_r.c index 92996f3..06b920e 100644 --- a/guts/getpwuid_r.c +++ b/guts/getpwuid_r.c @@ -10,8 +10,10 @@ setpwent(); while ((rc = wrap_getpwent_r(pwbuf, buf, buflen, pwbufp)) == 0) { /* 0 means no error occurred, and *pwbufp == pwbuf */ - if (pwbuf->pw_uid == uid) + if (pwbuf->pw_uid == uid) { + endpwent(); return rc; + } } endpwent(); /* we never found a match; rc is 0 if there was no error, or diff --git a/guts/mkdtemp.c b/guts/mkdtemp.c index 54f8759..fb23bc3 100644 --- a/guts/mkdtemp.c +++ b/guts/mkdtemp.c @@ -32,13 +32,14 @@ if (real___xstat64(_STAT_VER, rc, &buf) != -1) { pseudo_client_op(OP_CREAT, 0, -1, -1, tmp_template, &buf); } else { - pseudo_debug(1, "mkstemp (path %s) succeeded, but fstat failed (%s).\n", + pseudo_debug(1, "mkdtemp (path %s) succeeded, but fstat failed (%s).\n", rc, strerror(errno)); } errno = save_errno; } /* mkdtemp only changes the XXXXXX at the end. */ memcpy(template + len - 6, tmp_template + strlen(tmp_template) - 6, 6); + rc = template; free(tmp_template); /* return rc; * } diff --git a/guts/mktemp.c b/guts/mktemp.c index 2d2d927..7cf594a 100644 --- a/guts/mktemp.c +++ b/guts/mktemp.c @@ -28,6 +28,7 @@ * a file -- note the race condition implied here. */ memcpy(template + len - 6, tmp_template + strlen(tmp_template) - 6, 6); + rc = template; free(tmp_template); /* return rc; diff --git a/guts/readlinkat.c b/guts/readlinkat.c index d483ab5..5282e2b 100644 --- a/guts/readlinkat.c +++ b/guts/readlinkat.c @@ -6,7 +6,15 @@ * wrap_readlinkat(int dirfd, const char *path, char *buf, size_t bufsiz) { * ssize_t rc = -1; */ +#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS + if (dirfd != AT_FDCWD) { + errno = ENOSYS; + return -1; + } + rc = real_readlink(path, buf, bufsiz); +#else rc = real_readlinkat(dirfd, path, buf, bufsiz); +#endif if (rc > 0) { rc = pseudo_dechroot(buf, rc); diff --git a/pseudo_client.c b/pseudo_client.c index 421fe61..a8550ef 100644 --- a/pseudo_client.c +++ b/pseudo_client.c @@ -124,6 +124,7 @@ pseudo_pwd_lck_open(void) { return -1; } } + pseudo_pwd_lck_close(); pseudo_pwd_lck_fd = PSEUDO_ETC_FILE(".pwd.lock", pseudo_pwd_lck_name, O_RDWR | O_CREAT); return pseudo_pwd_lck_fd; @@ -750,6 +751,9 @@ base_path(int dirfd, const char *path, int leave_last) { size_t minlen = 0; char *newpath; + if (!path) + return NULL; + if (path[0] != '/') { if (dirfd != -1 && dirfd != AT_FDCWD) { if (dirfd >= 0) { diff --git a/pseudo_server.c b/pseudo_server.c index 7563700..4a474d0 100644 --- a/pseudo_server.c +++ b/pseudo_server.c @@ -326,7 +326,7 @@ serve_client(int i) { die_peacefully = 1; } } - if ((rc = pseudo_msg_send(client_fds[i], in, 0, NULL)) != 0) + if ((rc = pseudo_msg_send(clients[i].fd, in, -1, response_path)) != 0) pseudo_debug(1, "failed to send response to client %d [%d]: %d (%s)\n", i, (int) client_pids[i], rc, strerror(errno)); rc = in->op; diff --git a/pseudo_util.c b/pseudo_util.c index bef86ad..62ad848 100644 --- a/pseudo_util.c +++ b/pseudo_util.c @@ -646,7 +646,11 @@ pseudo_etc_file(const char *file, char *realname, int flags, char **search_dirs, continue; snprintf(filename, pseudo_path_max(), "%s/etc/%s", s, file); - rc = open(filename, flags); + if (flags & O_CREAT) { + rc = open(filename, flags, 0600); + } else { + rc = open(filename, flags); + } if (rc >= 0) { if (realname) strcpy(realname, filename); @@ -664,7 +668,11 @@ pseudo_etc_file(const char *file, char *realname, int flags, char **search_dirs, snprintf(filename, pseudo_path_max(), "/etc/%s", file); pseudo_debug(2, "falling back on <%s> for <%s>\n", filename, file); - rc = open(filename, flags); + if (flags & O_CREAT) { + rc = open(filename, flags, 0600); + } else { + rc = open(filename, flags); + } if (rc >= 0 && realname) strcpy(realname, filename); return rc; diff --git a/wrapfuncs.in b/wrapfuncs.in index c572ddf..ac3c828 100644 --- a/wrapfuncs.in +++ b/wrapfuncs.in @@ -82,7 +82,7 @@ long pathconf(const char *path, int name); char *realpath(const char *name, char *resolved_name); int remove(const char *path); /* flags=AT_SYMLINK_NOFOLLOW */ DIR *opendir(const char *path); -int scandir(const char *path, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const void *, const void *)); +int scandir(const char *path, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)()); char *tempnam(const char *template, const char *pfx); char *tmpnam(char *s); int truncate(const char *path, off_t length); diff --git a/wrapfuncs64.in b/wrapfuncs64.in index 4e6ad34..90aba48 100644 --- a/wrapfuncs64.in +++ b/wrapfuncs64.in @@ -11,5 +11,5 @@ int nftw64(const char *path, int (*fn)(const char *, const struct stat64 *, int, FILE *freopen64(const char *path, const char *mode, FILE *stream); int ftw64(const char *path, int (*fn)(const char *, const struct stat64 *, int), int nopenfd); int glob64(const char *pattern, int flags, int (*errfunc)(const char *, int), glob64_t *pglob); -int scandir64(const char *path, struct dirent64 ***namelist, int (*filter)(const struct dirent64 *), int (*compar)(const void *, const void *)); +int scandir64(const char *path, struct dirent64 ***namelist, int (*filter)(const struct dirent64 *), int (*compar)()); int truncate64(const char *path, off64_t length); |