ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/CCSAdmin/chsh.c
(Generate patch)

Comparing CCSAdmin/chsh.c (file contents):
Revision 567 by douglas, 2005-08-28T22:42:38-07:00 vs.
Revision 569 by douglas, 2005-08-28T23:50:17-07:00

# Line 4 | Line 4
4   //
5   // Change Shell
6  
7 #include <sys/utsname.h>
8
7   #include "common.h"
8  
9   int main(int argc, char *argv[])
# Line 32 | Line 30 | int main(int argc, char *argv[])
30                  return 1;
31          }
32  
35        char user[MAXLOGNAME] = "", *shell = NULL;
36        regex_t shell_;
37
33          typedef struct
34          {
35                  const char *name;
# Line 73 | Line 68 | int main(int argc, char *argv[])
68          char shell_regex_[strlen(shell_regex) + 12];
69  
70          sprintf(shell_regex_, "^-shell=(%s)$", shell_regex);
71 +
72 +        regex_t shell_;
73 +
74          regcheck(regcomp(&shell_, shell_regex_, REG_EXTENDED), &shell_, environment);
75  
76 +        char user[MAXLOGNAME] = "", *shell = NULL;
77 +
78          if (!getuid())
79          {
80                  regex_t user_;
# Line 132 | Line 132 | on:    regfree(&shell_);
132          {
133                  sprintf(shell_regex_, "^%s$", shell_regex);
134                  regcheck(regcomp(&shell_, shell_regex_, REG_EXTENDED), &shell_, environment);
135 +
136                  do
137                  {
138                          printf("Shell (");
# Line 173 | Line 174 | on:    regfree(&shell_);
174  
175   no:     check(setuid(geteuid()), environment);
176  
176        int pipe_[2];
177
178        check(pipe(pipe_), environment);
179
177          pid_t bash_;
178  
179          if (!(bash_ = check(fork(), environment)))
180          {
184                check(dup2(pipe_[0], 0), environment);
185                check(close(pipe_[1]), environment);
181                  check(setenv("USER", user, 1), environment);
182 +                check(setenv("FREEBSD", shells_->freebsd, 1), environment);
183 +                check(setenv("LINUX", shells_->linux, 1), environment);
184 +                check(setenv("DARWIN", shells_->darwin, 1), environment);
185                  check(execl("/ccs/bin/chsh.sh", argv[0], NULL), environment);
186          }
187  
190        check(close(pipe_[0]), environment);
191
192        FILE *sed = fdopen(pipe_[1], "w");
193
194        if (fprintf(sed, "%s\n%s\n%s\n", shells_->freebsd, shells_->linux, shells_->darwin) < 0)
195                longjmp(environment, 1);
196
197        if (fclose(sed))
198                longjmp(environment, 1);
199
188          int status;
189  
190          check(waitpid(bash_, &status, 0), environment);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines