/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/usplash.c

  • Committer: Teddy Hogeborn
  • Date: 2016-11-26 23:21:16 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 356.
  • Revision ID: teddy@recompile.se-20161126232116-nhqk9x1qij09b7cx
Add comment in documentation source with clarifying text.

* intro.xml (INTRODUCTION): Add comment with clarification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/*
3
3
 * Usplash - Read a password from usplash and output it
4
4
 * 
5
 
 * Copyright © 2008-2011 Teddy Hogeborn
6
 
 * Copyright © 2008-2011 Björn Påhlsson
 
5
 * Copyright © 2008-2016 Teddy Hogeborn
 
6
 * Copyright © 2008-2016 Björn Påhlsson
7
7
 * 
8
8
 * This program is free software: you can redistribute it and/or
9
9
 * modify it under the terms of the GNU General Public License as
19
19
 * along with this program.  If not, see
20
20
 * <http://www.gnu.org/licenses/>.
21
21
 * 
22
 
 * Contact the authors at <mandos@fukt.bsnet.se>.
 
22
 * Contact the authors at <mandos@recompile.se>.
23
23
 */
24
24
 
25
25
#define _GNU_SOURCE             /* asprintf(), TEMP_FAILURE_RETRY() */
36
36
                                   dirent */
37
37
#include <stddef.h>             /* NULL */
38
38
#include <string.h>             /* strlen(), memcmp(), strerror() */
39
 
#include <stdio.h>              /* asprintf(), vasprintf(), vprintf(), fprintf() */
 
39
#include <stdio.h>              /* asprintf(), vasprintf(), vprintf(),
 
40
                                   fprintf() */
40
41
#include <unistd.h>             /* close(), write(), readlink(),
41
42
                                   read(), STDOUT_FILENO, sleep(),
42
43
                                   fork(), setuid(), geteuid(),
57
58
const char usplash_name[] = "/sbin/usplash";
58
59
 
59
60
/* Function to use when printing errors */
60
 
void error_plus(int status, int errnum, const char *formatstring, ...){
 
61
__attribute__((format (gnu_printf, 3, 4)))
 
62
void error_plus(int status, int errnum, const char *formatstring,
 
63
                ...){
61
64
  va_list ap;
62
65
  char *text;
63
66
  int ret;
64
67
  
65
68
  va_start(ap, formatstring);
66
69
  ret = vasprintf(&text, formatstring, ap);
67
 
  if (ret == -1){
68
 
    fprintf(stderr, "Mandos plugin %s: ", program_invocation_short_name);
 
70
  if(ret == -1){
 
71
    fprintf(stderr, "Mandos plugin %s: ",
 
72
            program_invocation_short_name);
69
73
    vfprintf(stderr, formatstring, ap);
70
74
    fprintf(stderr, ": ");
71
75
    fprintf(stderr, "%s\n", strerror(errnum));
113
117
      ret = asprintf(&cmd_line_alloc, "%s %s", cmd, arg);
114
118
      if(ret == -1){
115
119
        int e = errno;
116
 
        TEMP_FAILURE_RETRY(close(*fifo_fd_r));
 
120
        close(*fifo_fd_r);
117
121
        errno = e;
118
122
        return false;
119
123
      }
129
133
                 cmd_line_len - written);
130
134
    if(sret == -1){
131
135
      int e = errno;
132
 
      TEMP_FAILURE_RETRY(close(*fifo_fd_r));
 
136
      close(*fifo_fd_r);
133
137
      free(cmd_line_alloc);
134
138
      errno = e;
135
139
      return false;
487
491
        error_plus(0, errno, "read");
488
492
        status = EX_OSERR;
489
493
      }
490
 
      TEMP_FAILURE_RETRY(close(outfifo_fd));
 
494
      close(outfifo_fd);
491
495
      goto failure;
492
496
    }
493
497
    if(interrupted_by_signal){
574
578
  
575
579
  /* Close FIFO */
576
580
  if(fifo_fd != -1){
577
 
    ret = (int)TEMP_FAILURE_RETRY(close(fifo_fd));
 
581
    ret = close(fifo_fd);
578
582
    if(ret == -1 and errno != EINTR){
579
583
      error_plus(0, errno, "close");
580
584
    }
583
587
  
584
588
  /* Close output FIFO */
585
589
  if(outfifo_fd != -1){
586
 
    ret = (int)TEMP_FAILURE_RETRY(close(outfifo_fd));
 
590
    ret = close(outfifo_fd);
587
591
    if(ret == -1){
588
592
      error_plus(0, errno, "close");
589
593
    }
651
655
  
652
656
  /* Close FIFO (again) */
653
657
  if(fifo_fd != -1){
654
 
    ret = (int)TEMP_FAILURE_RETRY(close(fifo_fd));
 
658
    ret = close(fifo_fd);
655
659
    if(ret == -1 and errno != EINTR){
656
660
      error_plus(0, errno, "close");
657
661
    }