/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-10-02 19:18:24 UTC
  • mto: This revision was merged to the branch mainline in revision 505.
  • Revision ID: belorn@fukt.bsnet.se-20111002191824-eweh4pvneeg3qzia
transitional stuff actually working
documented change to D-Bus API

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-2018 Teddy Hogeborn
6
 
 * Copyright © 2008-2018 Björn Påhlsson
7
 
 * 
8
 
 * This file is part of Mandos.
9
 
 * 
10
 
 * Mandos is free software: you can redistribute it and/or modify it
11
 
 * under the terms of the GNU General Public License as published by
12
 
 * the Free Software Foundation, either version 3 of the License, or
13
 
 * (at your option) any later version.
14
 
 * 
15
 
 * Mandos is distributed in the hope that it will be useful, but
 
5
 * Copyright © 2008-2011 Teddy Hogeborn
 
6
 * Copyright © 2008-2011 Björn Påhlsson
 
7
 * 
 
8
 * This program is free software: you can redistribute it and/or
 
9
 * modify it under the terms of the GNU General Public License as
 
10
 * published by the Free Software Foundation, either version 3 of the
 
11
 * License, or (at your option) any later version.
 
12
 * 
 
13
 * This program is distributed in the hope that it will be useful, but
16
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
17
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
16
 * General Public License for more details.
19
17
 * 
20
18
 * You should have received a copy of the GNU General Public License
21
 
 * along with Mandos.  If not, see <http://www.gnu.org/licenses/>.
 
19
 * along with this program.  If not, see
 
20
 * <http://www.gnu.org/licenses/>.
22
21
 * 
23
 
 * Contact the authors at <mandos@recompile.se>.
 
22
 * Contact the authors at <mandos@fukt.bsnet.se>.
24
23
 */
25
24
 
26
25
#define _GNU_SOURCE             /* asprintf(), TEMP_FAILURE_RETRY() */
59
58
const char usplash_name[] = "/sbin/usplash";
60
59
 
61
60
/* Function to use when printing errors */
62
 
__attribute__((format (gnu_printf, 3, 4)))
63
61
void error_plus(int status, int errnum, const char *formatstring,
64
62
                ...){
65
63
  va_list ap;
68
66
  
69
67
  va_start(ap, formatstring);
70
68
  ret = vasprintf(&text, formatstring, ap);
71
 
  if(ret == -1){
 
69
  if (ret == -1){
72
70
    fprintf(stderr, "Mandos plugin %s: ",
73
71
            program_invocation_short_name);
74
72
    vfprintf(stderr, formatstring, ap);
118
116
      ret = asprintf(&cmd_line_alloc, "%s %s", cmd, arg);
119
117
      if(ret == -1){
120
118
        int e = errno;
121
 
        close(*fifo_fd_r);
 
119
        TEMP_FAILURE_RETRY(close(*fifo_fd_r));
122
120
        errno = e;
123
121
        return false;
124
122
      }
134
132
                 cmd_line_len - written);
135
133
    if(sret == -1){
136
134
      int e = errno;
137
 
      close(*fifo_fd_r);
 
135
      TEMP_FAILURE_RETRY(close(*fifo_fd_r));
138
136
      free(cmd_line_alloc);
139
137
      errno = e;
140
138
      return false;
492
490
        error_plus(0, errno, "read");
493
491
        status = EX_OSERR;
494
492
      }
495
 
      close(outfifo_fd);
 
493
      TEMP_FAILURE_RETRY(close(outfifo_fd));
496
494
      goto failure;
497
495
    }
498
496
    if(interrupted_by_signal){
579
577
  
580
578
  /* Close FIFO */
581
579
  if(fifo_fd != -1){
582
 
    ret = close(fifo_fd);
 
580
    ret = (int)TEMP_FAILURE_RETRY(close(fifo_fd));
583
581
    if(ret == -1 and errno != EINTR){
584
582
      error_plus(0, errno, "close");
585
583
    }
588
586
  
589
587
  /* Close output FIFO */
590
588
  if(outfifo_fd != -1){
591
 
    ret = close(outfifo_fd);
 
589
    ret = (int)TEMP_FAILURE_RETRY(close(outfifo_fd));
592
590
    if(ret == -1){
593
591
      error_plus(0, errno, "close");
594
592
    }
656
654
  
657
655
  /* Close FIFO (again) */
658
656
  if(fifo_fd != -1){
659
 
    ret = close(fifo_fd);
 
657
    ret = (int)TEMP_FAILURE_RETRY(close(fifo_fd));
660
658
    if(ret == -1 and errno != EINTR){
661
659
      error_plus(0, errno, "close");
662
660
    }