Overview
Comment: | Updated to check return value of chdir() |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | 99eb34054944284b0ddc77f6d52123797b8bbaa1 |
User & Date: | rkeene on 2012-09-15 06:48:04 |
Other Links: | manifest | tags |
Context
2012-09-15
| ||
06:53 | Removed unneeded casts check-in: 413d9011a9 user: rkeene tags: trunk | |
06:48 | Updated to check return value of chdir() check-in: 99eb340549 user: rkeene tags: trunk | |
06:44 | Updated to check return value of waitpid() check-in: 316b02041a user: rkeene tags: trunk | |
Changes
Modified initrd/admin-tclkit/kitcreator-modules/system/system.c from [7ecfb38f87] to [7d48c39a12].
1886 1886 pid_t child, child_pgid = -1, waitpid_ret; 1887 1887 ssize_t read_ret; 1888 1888 time_t currtime; 1889 1889 char *argv[3], *envv[512]; 1890 1890 char *logfile, *filename, *cwd, *user, *group; 1891 1891 char logmsg[2048]; 1892 1892 fd_set read_fdset; 1893 - int pipe_ret, setsid_ret, execve_ret, tcl_ret, select_ret; 1893 + int pipe_ret, setsid_ret, execve_ret, tcl_ret, select_ret, chdir_ret; 1894 1894 int null_fd, log_fd, tmp_fd, max_fd; 1895 1895 int env_entry_objc; 1896 1896 int fds[2], fd; 1897 1897 int status; 1898 1898 int idx; 1899 1899 1900 1900 /* 1. Parse arguments */ ................................................................................ 2027 2027 } 2028 2028 2029 2029 /* 6. Setup environment */ 2030 2030 /* 6.a. Set umask */ 2031 2031 umask(umask_val); 2032 2032 2033 2033 /* 6.b. Set working directory */ 2034 - chdir(cwd); 2034 + chdir_ret = chdir(cwd); 2035 + if (chdir_ret != 0) { 2036 + write(fd, &child_pgid, sizeof(child_pgid)); 2037 + 2038 + _exit(0); 2039 + } 2035 2040 2036 2041 /* 6.c. Open log file for stderr and stdout */ 2037 2042 log_fd = open(logfile, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); 2038 2043 2039 2044 /* 6.d. Open "/dev/null" for stdin */ 2040 2045 null_fd = open("/dev/null", O_RDONLY); 2041 2046 if (null_fd < 0 || log_fd <0) {