here tried spawn bash using execle() , wanted set tmout environment new bash. worked well. see tmout environment variable new bash shell.
<example1> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(void) { char *env[] = {"tmout=60", null}; execle("/bin/bash", "bash", null, env); return 0; }
but if same thing example2 use sudo, cannot see tmout environment variable new shell.
<example2> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(void) { char *env[] = {"tmout=60", null}; execle("/bin/sudo", "sudo", "/bin/bash", null, null); return 0; }
i tried find example here. find information example1 above. not find information example2.
i tried following using putenv().
<example3> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(void) { putenv("tmout=60"); execle("/bin/sudo", "sudo", "/bin/bash", null, null); return 0; }
but example3 didn't work. can please give me idea how set environment when use sudo this?
Comments
Post a Comment