/mandos/trunk

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

« back to all changes in this revision

Viewing changes to plugins.d/usplash.c

  • Committer: Björn Påhlsson
  • Date: 2011-06-23 22:27:15 UTC
  • mto: This revision was merged to the branch mainline in revision 485.
  • Revision ID: belorn@fukt.bsnet.se-20110623222715-q5wro9ma9iyjl367
* Makefile (CFLAGS): Added "-lrt" to include real time library.
* plugins.d/mandos-client.c: use scandir(3) instead of readdir(3)
                             Prefix all debug output with "Mandos plugin " + program_invocation_short_name
                             Retry servers that failed to provide password.
                             New option --retry SECONDS that sets the interval between rechecking.
                             --retry also controls how often it retries a server when using --connect.
* plugins.d/splashy.c:  Prefix all debug output with "Mandos plugin " + program_invocation_short_name
* plugins.d/usplash.c: --||--
* plugins.d/askpass-fifo.c: --||--
* plugins.d/password-prompt.c: --||--
* plugins.d/plymouth.c: --||--
* mandos: Lower logger level from warning to info on failed client requests because client was disabled or unknown fingerprint.
* plugins.d/plymouth.c (get_pid): bug fix. Was not calling free on direntries. 

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-2014 Teddy Hogeborn
6
 
 * Copyright © 2008-2014 Björn Påhlsson
 
5
 * Copyright © 2008-2011 Teddy Hogeborn
 
6
 * Copyright © 2008-2011 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@recompile.se>.
 
22
 * Contact the authors at <mandos@fukt.bsnet.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(),
40
 
                                   fprintf() */
 
39
#include <stdio.h>              /* asprintf(), vasprintf(), vprintf(), fprintf() */
41
40
#include <unistd.h>             /* close(), write(), readlink(),
42
41
                                   read(), STDOUT_FILENO, sleep(),
43
42
                                   fork(), setuid(), geteuid(),
58
57
const char usplash_name[] = "/sbin/usplash";
59
58
 
60
59
/* Function to use when printing errors */
61
 
__attribute__((format (gnu_printf, 3, 4)))
62
 
void error_plus(int status, int errnum, const char *formatstring,
63
 
                ...){
 
60
void error_plus(int status, int errnum, const char *formatstring, ...){
64
61
  va_list ap;
65
62
  char *text;
66
63
  int ret;
67
64
  
68
65
  va_start(ap, formatstring);
69
66
  ret = vasprintf(&text, formatstring, ap);
70
 
  if(ret == -1){
71
 
    fprintf(stderr, "Mandos plugin %s: ",
72
 
            program_invocation_short_name);
 
67
  if (ret == -1){
 
68
    fprintf(stderr, "Mandos plugin %s: ", program_invocation_short_name);
73
69
    vfprintf(stderr, formatstring, ap);
74
70
    fprintf(stderr, ": ");
75
71
    fprintf(stderr, "%s\n", strerror(errnum));
117
113
      ret = asprintf(&cmd_line_alloc, "%s %s", cmd, arg);
118
114
      if(ret == -1){
119
115
        int e = errno;
120
 
        close(*fifo_fd_r);
 
116
        TEMP_FAILURE_RETRY(close(*fifo_fd_r));
121
117
        errno = e;
122
118
        return false;
123
119
      }
133
129
                 cmd_line_len - written);
134
130
    if(sret == -1){
135
131
      int e = errno;
136
 
      close(*fifo_fd_r);
 
132
      TEMP_FAILURE_RETRY(close(*fifo_fd_r));
137
133
      free(cmd_line_alloc);
138
134
      errno = e;
139
135
      return false;
491
487
        error_plus(0, errno, "read");
492
488
        status = EX_OSERR;
493
489
      }
494
 
      close(outfifo_fd);
 
490
      TEMP_FAILURE_RETRY(close(outfifo_fd));
495
491
      goto failure;
496
492
    }
497
493
    if(interrupted_by_signal){
578
574
  
579
575
  /* Close FIFO */
580
576
  if(fifo_fd != -1){
581
 
    ret = close(fifo_fd);
 
577
    ret = (int)TEMP_FAILURE_RETRY(close(fifo_fd));
582
578
    if(ret == -1 and errno != EINTR){
583
579
      error_plus(0, errno, "close");
584
580
    }
587
583
  
588
584
  /* Close output FIFO */
589
585
  if(outfifo_fd != -1){
590
 
    ret = close(outfifo_fd);
 
586
    ret = (int)TEMP_FAILURE_RETRY(close(outfifo_fd));
591
587
    if(ret == -1){
592
588
      error_plus(0, errno, "close");
593
589
    }
655
651
  
656
652
  /* Close FIFO (again) */
657
653
  if(fifo_fd != -1){
658
 
    ret = close(fifo_fd);
 
654
    ret = (int)TEMP_FAILURE_RETRY(close(fifo_fd));
659
655
    if(ret == -1 and errno != EINTR){
660
656
      error_plus(0, errno, "close");
661
657
    }