Bug 1542237

Summary: chpasswd segfaults
Product: [Fedora] Fedora Reporter: Dusty Mabe <dustymabe>
Component: libxcryptAssignee: Björn Esser (besser82) <besser82>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: besser82, fweimer, jlebon, miabbott, pvrabec, tmraz
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: shadow-utils-4.5-9.fc28 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-06 10:36:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dusty Mabe 2018-02-05 21:30:44 UTC
Description of problem:

When booting an atomic cloud image cloud-init can't set passwords because chpasswd segfaults:

```
[   12.847054] chpasswd[1241]: segfault at fffffffff1517020 ip 00007f8af0fd06a6 sp 00007ffd9db8c6e8 error 5 in libc-2.26.9000.so[7f8af0f38000+1b5000]
```

If you can get in to the system you can also see the same problem:

```
[root@vanilla-f28atomic ~]# rpm -q shadow-utils
shadow-utils-4.5-8.fc28.x86_64
[root@vanilla-f28atomic ~]# echo 'vagrant:password' | chpasswd 
Segmentation fault (core dumped)
```

How reproducible:

Always

Comment 1 Micah Abbott 2018-02-05 21:45:20 UTC
Reproduced this myself:

# coredumpctl info chpasswd                                              
           PID: 2325 (chpasswd)                     
           UID: 0 (root)                            
           GID: 0 (root)                            
        Signal: 11 (SEGV)                           
     Timestamp: Mon 2018-02-05 21:44:29 UTC (28s ago)                                                    
  Command Line: chpasswd                            
    Executable: /usr/sbin/chpasswd                  
 Control Group: /user.slice/user-1000.slice/session-7.scope                                              
          Unit: session-7.scope                     
         Slice: user-1000.slice                     
       Session: 7                                   
     Owner UID: 1000 (cloud-user)                   
       Boot ID: 958c848d7b5c4934934a783d833c5b44    
    Machine ID: 2f3c3b3dcf374c2e8485a788fc8fa95a    
      Hostname: atomichost-by-dustymabe             
       Storage: /var/lib/systemd/coredump/core.chpasswd.0.958c848d7b5c4934934a783d833c5b44.2325.1517867069000000.lz4                                                                                               
       Message: Process 2325 (chpasswd) of user 0 dumped core.                                           
                                                    
                Stack trace of thread 2325:         
                #0  0x00007f7354d51de1 __strlen_avx2 (libc.so.6)                                         
                #1  0x000055d2d0d74223 pw_encrypt (chpasswd)                                             
                #2  0x000055d2d0d7271b main (chpasswd)                                                   
                #3  0x00007f7354c181bb __libc_start_main (libc.so.6)                                     
                #4  0x000055d2d0d7311a _start (chpasswd)

Comment 2 Jonathan Lebon 2018-02-05 22:26:07 UTC
FWIW, this is not an issue in 4.5-7, so this is probably related to the libxcrypt system-wide change?

Comment 3 Tomas Mraz 2018-02-06 09:32:52 UTC
Yes, it is. Apparently it is no longer sufficient to include unistd.h for crypt() function prototype declaration. Is that intentional?

Comment 4 Tomas Mraz 2018-02-06 09:34:19 UTC
It looks to me like posix breakage.

Comment 5 Björn Esser (besser82) 2018-02-06 10:04:48 UTC
(In reply to Tomas Mraz from comment #4)
> It looks to me like posix breakage.


Nope, see [1].  One can rely on having crypt(), etc. to be present only, if _XOPEN_CRYPT is defined and if it is defined to have a value other than -1.

I'll add a fix to shadow-utils fixing this.


[1]  
http://pubs.opengroup.org/onlinepubs/007904875/basedefs/xbd_chap02.html#tag_02_01_05_02

Comment 6 Björn Esser (besser82) 2018-02-06 10:36:54 UTC
https://koji.fedoraproject.org/koji/buildinfo?buildID=1024219

Comment 7 Tomas Mraz 2018-02-06 10:45:18 UTC
Why did you reformat all the patches? It is just unnecessary noise. Please refrain from doing such non-sense changes on packages just because you're provenpackager.

Comment 8 Björn Esser (besser82) 2018-02-06 10:55:18 UTC
Sry, I didn't mean to reformat them, but I regenerated them in one run to align many of them to some changes in lines numbering.