/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/password-prompt.c

  • Committer: Teddy Hogeborn
  • Date: 2011-02-27 17:46:47 UTC
  • Revision ID: teddy@fukt.bsnet.se-20110227174647-oc7prq1d63lfkn2e
* debian/control (mandos-client): Fix syntax of conflicts line.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
#define _GNU_SOURCE             /* getline(), asprintf() */
26
26
 
27
 
#include <termios.h>            /* struct termios, tcsetattr(),
 
27
#include <termios.h>            /* struct termios, tcsetattr(),
28
28
                                   TCSAFLUSH, tcgetattr(), ECHO */
29
29
#include <unistd.h>             /* struct termios, tcsetattr(),
30
30
                                   STDIN_FILENO, TCSAFLUSH,
50
50
#include <iso646.h>             /* or, not */
51
51
#include <stdbool.h>            /* bool, false, true */
52
52
#include <inttypes.h>           /* strtoumax() */
53
 
#include <sys/stat.h>           /* struct stat, lstat(), open() */
54
 
#include <string.h>             /* strlen, rindex, memcmp */
 
53
#include <sys/stat.h>           /* struct stat, lstat(), open() */
 
54
#include <string.h>             /* strlen, rindex, memcmp */
55
55
#include <argp.h>               /* struct argp_option, struct
56
56
                                   argp_state, struct argp,
57
57
                                   argp_parse(), error_t,
67
67
const char *argp_program_version = "password-prompt " VERSION;
68
68
const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>";
69
69
 
70
 
/* Needed for conflict resolution */
71
 
const char plymouth_name[] = "plymouthd";
 
70
/* Needed for conflic resolution */
 
71
const char plymouthd_name[] = "plymouthd";
 
72
 
72
73
 
73
74
static void termination_handler(int signum){
74
75
  if(quit_now){
100
101
    }
101
102
    
102
103
    char *cmdline_filename;
103
 
    ret = asprintf(&cmdline_filename, "/proc/%s/cmdline",
104
 
                   proc_entry->d_name);
 
104
    ret = asprintf(&cmdline_filename, "/proc/%s/cmdline", proc_entry->d_name);
105
105
    if(ret == -1){
106
106
      error(0, errno, "asprintf");
107
107
      return 0;
108
108
    }
109
109
    
110
 
    /* Open /proc/<pid>/cmdline */
 
110
    /* Open /proc/<pid>/cmdline  */
111
111
    cl_fd = open(cmdline_filename, O_RDONLY);
112
112
    free(cmdline_filename);
113
113
    if(cl_fd == -1){
165
165
      cmdline_base = cmdline;
166
166
    }
167
167
    
168
 
    if(strcmp(cmdline_base, plymouth_name) != 0){
169
 
      if(debug){
170
 
        fprintf(stderr, "\"%s\" is not \"%s\"\n", cmdline_base,
171
 
                plymouth_name);
172
 
      }
 
168
    if(strcmp(cmdline_base, plymouthd_name) != 0){
173
169
      free(cmdline);
174
170
      return 0;
175
171
    }
176
 
    if(debug){
177
 
      fprintf(stderr, "\"%s\" equals \"%s\"\n", cmdline_base,
178
 
              plymouth_name);
179
 
    }
180
172
    free(cmdline);
181
173
    return 1;
182
174
  }
183
 
  
 
175
 
184
176
  struct dirent **direntries;
185
177
  int ret;
186
178
  ret = scandir("/proc", &direntries, is_plymouth, alphasort);
275
267
 
276
268
  if (conflict_detection()){
277
269
    if(debug){
278
 
      fprintf(stderr, "Stopping %s because of conflict\n", argv[0]);
 
270
      fprintf(stderr, "Stopping %s because of conflict", argv[0]);
279
271
    }
280
272
    return EXIT_FAILURE;
281
273
  }
483
475
        break;
484
476
      }
485
477
    }
486
 
    /* if(sret == 0), then the only sensible thing to do is to retry
487
 
       to read from stdin */
 
478
    /* if(sret == 0), then the only sensible thing to do is to retry to
 
479
       read from stdin */
488
480
    fputc('\n', stderr);
489
481
    if(debug and not quit_now){
490
482
      /* If quit_now is nonzero, we were interrupted by a signal, and