Bug 1324110 - Unexpected "write error" reported by tar when using it in a pipe
Summary: Unexpected "write error" reported by tar when using it in a pipe
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: fprintd
Version: 6.7
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: Bastien Nocera
QA Contact: Desktop QE
URL:
Whiteboard:
Depends On:
Blocks: 1269194
TreeView+ depends on / blocked
 
Reported: 2016-04-05 14:18 UTC by Zdenek Pytela
Modified: 2019-11-14 07:43 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-08-02 21:20:30 UTC
Target Upstream Version:


Attachments (Terms of Use)
Ltrace log (27.89 KB, application/x-gzip)
2016-04-25 09:31 UTC, Pavel Raiskup
no flags Details

Description Zdenek Pytela 2016-04-05 14:18:47 UTC
Description of problem:
Under some conditions, tar reports a "write error" message.

Version-Release number of selected component (if applicable):
tar-1.23-14.el6.x86_64 (latest)
tar-1.23-7.el6.x86_64 (fixed a similar problem)

How reproducible:
always

Steps to Reproduce:
1. user2 has tcsh or ksh as a login shell
2. log on server as user1 (console, ssh)
3. execute "su - user2" command
4. tar czf file.tgz /etc/{passwd,group}
5. tar tzf file.tgz | head -1

Actual results:
etc/passwd
tar: write error


Expected results:
etc/passwd


Additional info:
- reproduced in ksh and tcsh, local user, tar/gtar, gnu/posix type of archive
- not reproduced in bash, but bash might be affected as well
- not reproduced without gzip
- not reproduced when steps are not exactly the same: login as a non-root user first is required

Similar problem was solved in this bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=807728

Comment 2 Pavel Raiskup 2016-04-20 10:29:24 UTC
I'm not able to reproduce this in tcsh/ksh.  Zdeňek, have you been able to
reproduce this?

Comment 3 Zdenek Pytela 2016-04-20 12:24:46 UTC
Pavel,

I reproduced it on my vm the same way as the customer. All the steps described are necessary.

Comment 4 Pavel Raiskup 2016-04-20 12:38:32 UTC
Not reproducible for me, though:

Last login: Wed Apr 20 14:35:06 2016 from 192.168.122.1
[tcshuser@localhost ~]$ ps
  PID TTY          TIME CMD
 4408 pts/0    00:00:00 csh
 4417 pts/0    00:00:00 ps
[tcshuser@localhost ~]$ su - kshuser
Password: 
$ tar czf file.tgz /etc/{passwd,group}
tar: Removing leading `/' from member names
$ tar tzf file.tgz | head -1
etc/passwd
$ tar tzf file.tgz | :      
$ ps
  PID TTY          TIME CMD
 4422 pts/0    00:00:00 ksh
 4438 pts/0    00:00:00 ps
$ rpm -q tar tcsh ksh bash
tar-1.23-13.el6.x86_64
tcsh-6.17-25.el6_6.x86_64
ksh-20120801-28.el6_7.3.x86_64
bash-4.1.2-33.el6_7.1.x86_64

Comment 5 Zdenek Pytela 2016-04-20 13:08:14 UTC
Here, reproduced again:

$ ssh user1@rhel6
Last login: Wed Apr 20 15:01:06 2016 from 192.168.122.1
[user1@user1-rhel67 ~]$ ps
  PID TTY          TIME CMD
23948 pts/1    00:00:00 bash
23985 pts/1    00:00:00 ps
$ su - kuser2
Password:
$ tar czf file.tgz /etc/{passwd,group}
tar: Removing leading `/' from member names
$ tar tzf file.tgz | head -1
etc/passwd
tar: write error
$ tar tzf file.tgz | :
tar: write error
$ ps
  PID TTY          TIME CMD
23995 pts/1    00:00:00 ksh
24019 pts/1    00:00:00 ps
$ rpm -q tar tcsh ksh bash
tar-1.23-13.el6.x86_64
tcsh-6.17-25.el6_6.x86_64
ksh-20120801-28.el6_7.3.x86_64
bash-4.1.2-33.el6_7.1.x86_64

RHEL 6, all packages updated.
What else can I do now?

Comment 8 Pavel Raiskup 2016-04-22 14:28:16 UTC
Thanks, the issue is that PAM (called from 'su' binary) for some reason
SIG_IGN'ores SIGPIPE while switching from ksh user (user1) to tcsh
user (user2).

Tar is then started in environment where SIGPIPE is blocked
and thus it is not terminated automatically by that signal -- that is why
(even though the SIGPIPE came) tar tries to write to 'stdout' and ends 
with this error message.

I'm not sure the SIGPIPE should be ignored before subsequent process is
started, so switching ot pam.

Comment 9 Tomas Mraz 2016-04-25 08:14:15 UTC
What are the PAM modules configured for su? I.E. what is the contents of /etc/pam.d/su /etc/pam.d/su-l /etc/pam.d/system-auth?

I do not see any manipulation of SIGPIPE handler in PAM library and the modules that are part of the main pam package.

Comment 10 Zdenek Pytela 2016-04-25 09:11:32 UTC
The content is RHEL6 default:

cat /etc/pam.d/su-l
#%PAM-1.0
auth            include         su
account         include         su
password        include         su
session         optional        pam_keyinit.so force revoke
session         include         su

$ cat /etc/pam.d/su
#%PAM-1.0
auth            sufficient      pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth           sufficient      pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth           required        pam_wheel.so use_uid
auth            include         system-auth
account         sufficient      pam_succeed_if.so uid = 0 use_uid quiet
account         include         system-auth
password        include         system-auth
session         include         system-auth
session         optional        pam_xauth.so

Comment 12 Pavel Raiskup 2016-04-25 09:31:42 UTC
Created attachment 1150323 [details]
Ltrace log

Ltrace log obtained like:

$ ltrace -f -p 12371 -S

(the first pid traced is the ksh login shell of user1)

Comment 13 Tomas Mraz 2016-04-25 09:48:04 UTC
/etc/pam.d/system-auth contents:
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        sufficient    pam_fprintd.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 500 quiet
auth        required      pam_deny.so

account     required      pam_unix.so
account     sufficient    pam_localuser.so
account     sufficient    pam_succeed_if.so uid < 500 quiet
account     required      pam_permit.so

password    requisite     pam_cracklib.so try_first_pass retry=3 type=
password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so

Comment 14 Tomas Mraz 2016-04-25 09:51:29 UTC
This is most probably caused by the pam_fprintd.so. The sigaction from the ltrace above is missing reinstating of the original sigaction value.


Note You need to log in before you can comment on or make changes to this bug.