Set argv[0] to the - followed by the basename of the login shell.

This commit is contained in:
Kris Maglione 2007-03-15 19:01:58 -04:00
parent fd181a0a7e
commit d0e3417c07
2 changed files with 10 additions and 6 deletions

4
fs.c
View File

@ -239,13 +239,15 @@ message_root(char *message)
else if(!strncmp(message, "exec ", 5)) {
srv.running = 0;
execstr = strdup(&message[5]);
message += strlen(message);
}
else if(!strncmp(message, "view ", 5))
select_view(&message[5]);
else if(!strncmp(message, "selcolors ", 10)) {
fprintf(stderr, "wmiiwm: warning: selcolors have been removed\n");
return Ebadcmd;
}else if(!strncmp(message, "focuscolors ", 12)) {
}
else if(!strncmp(message, "focuscolors ", 12)) {
message += 12;
n = strlen(message);
return parse_colors(&message, (int *)&n, &def.focuscolor);

12
main.c
View File

@ -387,10 +387,12 @@ main(int argc, char *argv[]) {
/* Run through the user's shell as a login shell */
tmp = malloc(sizeof(char*) * (strlen(passwd->pw_shell) + 2));
/* Can't overflow */
sprintf(tmp, "-%s", passwd->pw_shell);
execl(passwd->pw_shell, tmp, "-c", wmiirc, nil);
if(passwd->pw_shell[0] == '/')
sprintf(tmp, "-%s", strrchr(passwd->pw_shell, '/') + 1); /* Can't overflow */
else
fatal("wmiiwm: shell is not an absolute path: %s\n", passwd->pw_shell);
execl(passwd->pw_shell, tmp, "-c", wmiirc, nil);
fatal("wmiiwm: can't exec \"%s\": %s\n", wmiirc, strerror(errno));
break; /* Not reached */
default:
@ -432,8 +434,8 @@ main(int argc, char *argv[]) {
num_screens = 1;
screens = emallocz(num_screens * sizeof(*screens));
for(sock = 0; sock < num_screens; sock++) {
s = &screens[sock];
for(i = 0; i < num_screens; i++) {
s = &screens[i];
s->lbar = nil;
s->rbar = nil;
s->sel = nil;