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

  • Committer: Teddy Hogeborn
  • Date: 2008-07-21 15:34:44 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080721153444-lugbjkj1oq65ugq3
* Makefile (CFLAGS): Changed to use $(WARN), $(DEBUG), $(COVERAGE) and
                     $(LANGUAGE).
  (WARN, DEBUG, COVERAGE, LANGUAGE): New.
  (LDFLAGS): New; use $(COVERAGE)

* plugbasedclient.c: Added copyright header.
  (process.buffer_size, process.buffer_length): Changed to "size_t".
  (main): Cast arguments to malloc and realloc.  Detect read errors
          from processes.

* mandosclient.c: Added copyright header.
  (interface): Moved to inside "main".
  (gpg_packet_decrypt): Renamed to "pgp_packet_decrypt"; all callers
                        changed.  Changed "new_packet_capacity" and
                        "new_packet_length" to be ssize_t.  Cast
                        arguments to realloc.
  (debuggnutls): Attribute "level" argument as unused.
  (empty_log): Attribute "level" and "txt" arguments as unused.
  (start_mandos_communication): New argument "if_index".  Bug fix:
                                check ret, no tcp_sd, for errors from
                                setsockopt.  Use "if_index" directly
                                instead of looking up the index.  Loop
                                around fwrite until all data is written.
  (resolve_callback): Attribute "txt", and "flags" as usused.  Added
                      default case to switch.  Also show server host
                      name.  Call start_mandos_communication with
                      "interface".
  (browse_callback): Added default case to switch.
  (main): Variable "interface" moved here.  Cast "srand" argument.
          Bug fix: Call avahi_s_service_browser_new with index of
          "interface", not "eth0".

* passprompt.c: Added copyright header.
  (termination_handler): Attribute "signum" argument as unused.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/*
3
3
 * Passprompt - Read a password from the terminal and print it
4
4
 *
5
 
 * Copyright © 2007-2008 Teddy Hogeborn & Björn Påhlsson
 
5
 * Copyright © 2007-2008 Teddy Hogeborn and Björn Påhlsson.
6
6
 * 
7
7
 * This program is free software: you can redistribute it and/or
8
8
 * modify it under the terms of the GNU General Public License as
23
23
 */
24
24
 
25
25
#define _GNU_SOURCE             /* getline() */
 
26
#define _FORTIFY_SOURCE 2
26
27
 
27
28
#include <termios.h>            /* struct termios, tcsetattr(),
28
29
                                   TCSAFLUSH, tcgetattr(), ECHO */
49
50
volatile bool quit_now = false;
50
51
bool debug = false;
51
52
 
52
 
static void termination_handler(__attribute__((unused))int signum){
 
53
void termination_handler(__attribute__((unused))int signum){
53
54
  quit_now = true;
54
55
}
55
56
 
102
103
  
103
104
  sigemptyset(&new_action.sa_mask);
104
105
  sigaddset(&new_action.sa_mask, SIGINT);
 
106
  sigaddset(&new_action.sa_mask, SIGQUIT);
105
107
  sigaddset(&new_action.sa_mask, SIGHUP);
106
108
  sigaddset(&new_action.sa_mask, SIGTERM);
107
109
  sigaction(SIGINT, NULL, &old_action);
108
110
  if (old_action.sa_handler != SIG_IGN)
109
111
    sigaction(SIGINT, &new_action, NULL);
 
112
  sigaction(SIGQUIT, NULL, &old_action);
 
113
  if (old_action.sa_handler != SIG_IGN)
 
114
    sigaction(SIGQUIT, &new_action, NULL);
110
115
  sigaction(SIGHUP, NULL, &old_action);
111
116
  if (old_action.sa_handler != SIG_IGN)
112
117
    sigaction(SIGHUP, &new_action, NULL);
146
151
      status = EXIT_SUCCESS;
147
152
      break;
148
153
    }
 
154
    // ret == 0 makes no other sence than to retry to read from stdin
149
155
    if (ret < 0){
150
156
      if (errno != EINTR and not feof(stdin)){
151
157
        perror("getline");
153
159
        break;
154
160
      }
155
161
    }
156
 
    /* if(ret == 0), then the only sensible thing to do is to retry to
157
 
       read from stdin */
158
162
    fputc('\n', stderr);
159
163
  }
160
 
  
 
164
 
161
165
  if (debug){
162
166
    fprintf(stderr, "Restoring terminal attributes\n");
163
167
  }
164
168
  if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &t_old) != 0){
165
169
    perror("tcsetattr+echo");
166
170
  }
167
 
  
 
171
 
168
172
  if (debug){
169
173
    fprintf(stderr, "%s is exiting\n", argv[0]);
170
174
  }