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

  • Committer: Björn Påhlsson
  • Date: 2011-06-18 22:51:12 UTC
  • mto: This revision was merged to the branch mainline in revision 485.
  • Revision ID: belorn@fukt.bsnet.se-20110618225112-rnt2m4ek32758f80
using scandir instead of readdir

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/*
3
3
 * Plymouth - Read a password from Plymouth and output it
4
4
 * 
5
 
 * Copyright © 2010 Teddy Hogeborn
6
 
 * Copyright © 2010 Björn Påhlsson
 
5
 * Copyright © 2010-2011 Teddy Hogeborn
 
6
 * Copyright © 2010-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
198
198
      return 0;
199
199
    }
200
200
  }
201
 
  char exe_target[sizeof(plymouth_path)];
 
201
  char exe_target[sizeof(plymouthd_path)];
202
202
  char *exe_link;
203
203
  ret = asprintf(&exe_link, "/proc/%s/exe", proc_entry->d_name);
204
204
  if(ret == -1){
225
225
  
226
226
  ssize_t sret = readlink(exe_link, exe_target, sizeof(exe_target));
227
227
  free(exe_link);
228
 
  if((sret != (ssize_t)sizeof(plymouth_path)-1) or
229
 
      (memcmp(plymouth_path, exe_target,
230
 
              sizeof(plymouth_path)-1) != 0)){
 
228
  if((sret != (ssize_t)sizeof(plymouthd_path)-1) or
 
229
      (memcmp(plymouthd_path, exe_target,
 
230
              sizeof(plymouthd_path)-1) != 0)){
231
231
    return 0;
232
232
  }
233
233
  return 1;
247
247
  if(maxvalue == 0){
248
248
    struct dirent **direntries;
249
249
    ret = scandir("/proc", &direntries, is_plymouth, alphasort);
250
 
    sscanf(direntries[0]->d_name, "%" SCNuMAX, &maxvalue);
 
250
    if (ret == -1){
 
251
      error(0, errno, "scandir");
 
252
    }
 
253
    if (ret > 0){
 
254
      ret = sscanf(direntries[0]->d_name, "%" SCNuMAX, &maxvalue);
 
255
      if (ret < 0){
 
256
        error(0, errno, "sscanf");
 
257
      }
 
258
    }
251
259
  }
252
260
  pid_t pid;
253
261
  pid = (pid_t)maxvalue;