/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

  • Committer: teddy at recompile
  • Date: 2020-11-29 22:54:26 UTC
  • mto: This revision was merged to the branch mainline in revision 402.
  • Revision ID: teddy@recompile.se-20201129225426-6ud4hwj36zo67igi
Fix flaky test in password-agent

The test_send_password_to_socket_EMSGSIZE function should not use a
hard-coded constant to trigger an EMSGSIZE error from send().

* dracut-module/password-agent.c (send_password_to_socket): Only save
  errno from send() if it returned < 0.  Show strerror(errno) if
  send() does return EMSGSIZE.  Show number of bytes sent if send()
  sends less than all bytes.
  (test_send_password_to_socket_EMSGSIZE): Do not skip this test on
  non-AMD64 platforms.  Try to find a suitable message size to trigger
  EMSGSIZE before testing send_password_to_socket(), and only skip
  this test if such a triggering message size is not found.

Reported-By: Simon McVittie <smcv@debian.org>
Closes: #975457

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
#include <unistd.h>             /* close(), SEEK_SET, off_t, write(),
81
81
                                   getuid(), getgid(), seteuid(),
82
82
                                   setgid(), pause(), _exit(),
83
 
                                   unlinkat(), lstat(), symlink() */
 
83
                                   unlinkat() */
84
84
#include <arpa/inet.h>          /* inet_pton(), htons() */
85
85
#include <iso646.h>             /* not, or, and */
86
86
#include <argp.h>               /* struct argp_option, error_t, struct
2715
2715
  }
2716
2716
  
2717
2717
  {
 
2718
    /* Work around Debian bug #633582:
 
2719
       <https://bugs.debian.org/633582> */
 
2720
    
2718
2721
    /* Re-raise privileges */
2719
2722
    ret = raise_privileges();
2720
2723
    if(ret != 0){
2723
2726
    } else {
2724
2727
      struct stat st;
2725
2728
      
2726
 
      /* Work around Debian bug #633582:
2727
 
         <https://bugs.debian.org/633582> */
2728
 
 
2729
2729
      if(strcmp(seckey, PATHDIR "/" SECKEY) == 0){
2730
2730
        int seckey_fd = open(seckey, O_RDONLY);
2731
2731
        if(seckey_fd == -1){
2790
2790
        }
2791
2791
      }
2792
2792
      
2793
 
      /* Work around Debian bug #981302
2794
 
         <https://bugs.debian.org/981302> */
2795
 
      if(lstat("/dev/fd", &st) != 0 and errno == ENOENT){
2796
 
        ret = symlink("/proc/self/fd", "/dev/fd");
2797
 
        if(ret == -1){
2798
 
          perror_plus("Failed to create /dev/fd symlink");
2799
 
        }
2800
 
      }
2801
 
 
2802
2793
      /* Lower privileges */
2803
2794
      ret = lower_privileges();
2804
2795
      if(ret != 0){