/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-03-01 20:35:04 UTC
  • mfrom: (469.1.1 mandos-local)
  • Revision ID: teddy@fukt.bsnet.se-20110301203504-2sp5wiq74jz1rl80
* plugins.d/password-prompt.c: Some white space fixes.  Break some
                               long lines.  Add more debug output.

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,
102
102
    }
103
103
    
104
104
    char *cmdline_filename;
105
 
    ret = asprintf(&cmdline_filename, "/proc/%s/cmdline", proc_entry->d_name);
 
105
    ret = asprintf(&cmdline_filename, "/proc/%s/cmdline",
 
106
                   proc_entry->d_name);
106
107
    if(ret == -1){
107
108
      error(0, errno, "asprintf");
108
109
      return 0;
109
110
    }
110
111
    
111
 
    /* Open /proc/<pid>/cmdline  */
 
112
    /* Open /proc/<pid>/cmdline */
112
113
    cl_fd = open(cmdline_filename, O_RDONLY);
113
114
    free(cmdline_filename);
114
115
    if(cl_fd == -1){
168
169
    
169
170
    if((strcmp(cmdline_base, plymouth_name) != 0)
170
171
       and (strcmp(cmdline_base, plymouth_alt_name) != 0)){
 
172
      if(debug){
 
173
        fprintf(stderr, "\"%s\" is not \"%s\" or \"%s\"\n",
 
174
                cmdline_base, plymouth_name, plymouth_alt_name);
 
175
      }
171
176
      free(cmdline);
172
177
      return 0;
173
178
    }
 
179
    fprintf(stderr, "\"%s\" equals \"%s\" or \"%s\"\n",
 
180
            cmdline_base, plymouth_name, plymouth_alt_name);
174
181
    free(cmdline);
175
182
    return 1;
176
183
  }
177
 
 
 
184
  
178
185
  struct dirent **direntries;
179
186
  int ret;
180
187
  ret = scandir("/proc", &direntries, is_plymouth, alphasort);
269
276
 
270
277
  if (conflict_detection()){
271
278
    if(debug){
272
 
      fprintf(stderr, "Stopping %s because of conflict", argv[0]);
 
279
      fprintf(stderr, "Stopping %s because of conflict\n", argv[0]);
273
280
    }
274
281
    return EXIT_FAILURE;
275
282
  }
477
484
        break;
478
485
      }
479
486
    }
480
 
    /* if(sret == 0), then the only sensible thing to do is to retry to
481
 
       read from stdin */
 
487
    /* if(sret == 0), then the only sensible thing to do is to retry
 
488
       to read from stdin */
482
489
    fputc('\n', stderr);
483
490
    if(debug and not quit_now){
484
491
      /* If quit_now is nonzero, we were interrupted by a signal, and