144 |
* Redirect the standard file descriptors |
* Redirect the standard file descriptors |
145 |
*/ |
*/ |
146 |
redirect_stdfd(); |
redirect_stdfd(); |
147 |
|
|
148 |
|
/* |
149 |
|
* Switch uid and gid if requested |
150 |
|
*/ |
151 |
|
if(c->has_gid) { |
152 |
|
if(0 == setgid(c->gid)) { |
153 |
|
log("Failed to change gid to '%d' for '%s'\n", |
154 |
|
c->gid, c->arg[0]); |
155 |
|
} |
156 |
|
} |
157 |
|
if(c->has_uid) { |
158 |
|
if(0 == setuid(c->uid)) { |
159 |
|
log("Failed to change uid to '%d' for '%s'\n", |
160 |
|
c->uid, c->arg[0]); |
161 |
|
} |
162 |
|
} |
163 |
|
|
164 |
/* |
/* |
165 |
* The exec statement done by the second child |
* The exec statement done by the second child |
166 |
*/ |
*/ |
235 |
P->arg[i]= xstrdup(C->arg[i]); |
P->arg[i]= xstrdup(C->arg[i]); |
236 |
P->arg[i]= NULL; |
P->arg[i]= NULL; |
237 |
|
|
238 |
|
P->uid= C->uid; |
239 |
|
P->gid= C->gid; |
240 |
|
P->has_uid= C->has_uid; |
241 |
|
P->has_gid= C->has_gid; |
242 |
|
|
243 |
return P; |
return P; |
244 |
|
|
245 |
} |
} |