Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore the original terminal pgrp after editing #1196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

millert
Copy link
Contributor

@millert millert commented Jan 24, 2025

This fixes a problem when the shell is not in monitor mode (job control enabled) which resulted in the terminal pgrp being set to an invalid value once vipw exited. Fixes #1194.

src/vipw.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@alejandro-colomar alejandro-colomar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested-by: Alejandro Colomar <[email protected]>
Reviewed-by: Alejandro Colomar <[email protected]>
alx@devuan:/srv/alx/src/shadow/shadow/master$ sudo bash
[sudo] password for alx: 
root@devuan:/srv/alx/src/shadow/shadow/master# set +m
root@devuan:/srv/alx/src/shadow/shadow/master# ./src/vipw
vipw: /etc/passwd is unchanged
root@devuan:/srv/alx/src/shadow/shadow/master# 
root@devuan:/srv/alx/src/shadow/shadow/master# exit
exit

Thanks!

This fixes a problem when the shell is not in monitor mode (job control
enabled) which resulted in the terminal pgrp being set to an invalid
value once vipw exited.

Fixes: 7eca111 (2019-11-11; "Fix vipw not resuming correctly when suspended")
Closes: <shadow-maint#1194>
Reported-by: <https://github.com/yonecle>
Tested-by: Alejandro Colomar <[email protected]>
Reviewed-by: Alejandro Colomar <[email protected]>
@alejandro-colomar
Copy link
Collaborator

I've applied some amendments to the commit (commit message formatting, and also removal of white space in source code):

$ git range-diff mt/master mt/pgrp_fix pgrp_fix 
1:  d61b626c ! 1:  7dcb9a0a Restore the original terminal pgrp after editing
    @@ Metadata
     Author: Todd C. Miller <[email protected]>
     
      ## Commit message ##
    -    Restore the original terminal pgrp after editing
    +    src/vipw.c: Restore the original terminal pgrp after editing
     
         This fixes a problem when the shell is not in monitor mode (job control
         enabled) which resulted in the terminal pgrp being set to an invalid
    -    value once vipw exited.  Fixes #1194.
    +    value once vipw exited.
    +
    +    Fixes: 7eca1112fbd7 (2019-11-11; "Fix vipw not resuming correctly when suspended")
    +    Closes: <https://github.com/shadow-maint/shadow/issues/1194>
    +    Reported-by: <https://github.com/yonecle>
    +    Tested-by: Alejandro Colomar <[email protected]>
    +    Reviewed-by: Alejandro Colomar <[email protected]>
     
      ## src/vipw.c ##
     @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
     +  if (orig_pgrp != -1) {
     +           /* Restore terminal pgrp after editing. */
     +          if (tcsetpgrp(STDIN_FILENO, orig_pgrp) == -1) {
    -+                  fprintf (stderr, "%s: %s: %s", Prog,
    -+                           "tcsetpgrp", strerror (errno));
    ++                  fprintf(stderr, "%s: %s: %s", Prog,
    ++                          "tcsetpgrp", strerror(errno));
     +          }
                sigprocmask(SIG_SETMASK, &omask, NULL);
     +  }

@alejandro-colomar
Copy link
Collaborator

Cc: @yonecle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vipw/vigr affect bash because it changes to PGID.
2 participants