/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: Teddy Hogeborn
  • Date: 2009-01-13 04:29:35 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090113042935-ztxe47n42q5z767b
* plugin-runner.c (main): Bug fix; do not accept a "d" character after
                          user ID or group ID numbers.  Bug fix: use
                          "%u" when printing PID of coredumped plugin,
                          not "%d".
* plugins.d/password-prompt.c (main): Remove comment which was copied
                                      from another program by mistake.
* plugins.d/splashy.c: Only comment changes.
* plugins.d/usplash.c: - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
                                   dirent */
37
37
#include <stddef.h>             /* NULL */
38
38
#include <string.h>             /* strlen(), memcmp() */
39
 
#include <stdio.h>              /* asprintf(), perror() */
 
39
#include <stdio.h>              /* asprintf(), perror(), sscanf() */
40
40
#include <unistd.h>             /* close(), write(), readlink(),
41
41
                                   read(), STDOUT_FILENO, sleep(),
42
42
                                   fork(), setuid(), geteuid(),
46
46
                                   EXIT_SUCCESS, malloc(), _exit() */
47
47
#include <stdlib.h>             /* getenv() */
48
48
#include <dirent.h>             /* opendir(), readdir(), closedir() */
49
 
#include <inttypes.h>           /* intmax_t, strtoimax() */
50
49
#include <sys/stat.h>           /* struct stat, lstat(), S_ISLNK */
51
50
 
52
51
sig_atomic_t interrupted_by_signal = 0;
171
170
        proc_ent != NULL;
172
171
        proc_ent = readdir(proc_dir)){
173
172
      pid_t pid;
174
 
      {
175
 
        intmax_t tmpmax;
176
 
        char *tmp;
177
 
        errno = 0;
178
 
        tmpmax = strtoimax(proc_ent->d_name, &tmp, 10);
179
 
        if(errno != 0 or tmp == proc_ent->d_name or *tmp != '\0'
180
 
           or tmpmax != (pid_t)tmpmax){
181
 
          /* Not a process */
182
 
          continue;
183
 
        }
184
 
        pid = (pid_t)tmpmax;
 
173
      /* In the GNU C library, pid_t is always int */
 
174
      ret = sscanf(proc_ent->d_name, "%d", &pid);
 
175
      if(ret != 1){
 
176
        /* Not a process */
 
177
        continue;
185
178
      }
186
179
      /* Find the executable name by doing readlink() on the
187
180
         /proc/<pid>/exe link */