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

  • Committer: Teddy Hogeborn
  • Date: 2009-01-13 01:36:46 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090113013646-1u21ie2oaotcekdz
* plugin-runner.c (main): Use "sscanf" instead of "strtol"; using the
                          correct type instead of casting.
* plugins.d/mandos-cliend.c (main): Detect an empty string when
                                    parsing DH bits and port number.
* plugins.d/splashy.c (main): Use "sscanf" instead of "strtoul"; using
                              the correct type instead of casting.
* plugins.d/usplash.c (main): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include <sys/types.h>          /* pid_t, DIR, struct dirent,
37
37
                                   ssize_t */
38
38
#include <dirent.h>             /* opendir(), readdir(), closedir() */
39
 
#include <inttypes.h>           /* intmax_t, SCNdMAX */
40
39
#include <sys/stat.h>           /* struct stat, lstat(), S_ISLNK */
41
40
#include <iso646.h>             /* not, or, and */
42
41
#include <unistd.h>             /* readlink(), fork(), execl(),
99
98
        proc_ent != NULL;
100
99
        proc_ent = readdir(proc_dir)){
101
100
      pid_t pid;
102
 
      {
103
 
        intmax_t tmpmax;
104
 
        int numchars;
105
 
        ret = sscanf(proc_ent->d_name, "%" SCNdMAX "%n", &tmpmax,
106
 
                     &numchars);
107
 
        if(ret < 1 or tmpmax != (pid_t)tmpmax
108
 
           or proc_ent->d_name[numchars] != '\0'){
109
 
          /* Not a process */
110
 
          continue;
111
 
        }
112
 
        pid = (pid_t)tmpmax;
 
101
      /* In the GNU C library, pid_t is always int */
 
102
      ret = sscanf(proc_ent->d_name, "%d", &pid);
 
103
      if(ret != 1){ 
 
104
        /* Not a process */
 
105
        continue;
113
106
      }
114
107
      /* Find the executable name by doing readlink() on the
115
108
         /proc/<pid>/exe link */
276
269
    /* Child; will become new splashy process */
277
270
    
278
271
    /* Make the effective user ID (root) the only user ID instead of
279
 
       the real user ID (_mandos) */
 
272
       the real user ID (mandos) */
280
273
    ret = setuid(geteuid());
281
274
    if(ret == -1){
282
275
      perror("setuid");