/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-10 02:39:56 UTC
  • mfrom: (257.1.2 mandos)
  • Revision ID: teddy@fukt.bsnet.se-20090110023956-o7f5r8af28fmgahw
Fixed warnings on AMD64, thanks to Mooie <mooie@cow.se> for the patch.

* plugins.d/askpass-fifo.c (main): Cast value from TEMP_FAILURE_RETRY
                                   to int, the value the inner
                                   function returns.
* plugins.d/mandos-client.c (init_gpgme): - '' -
  (start_mandos_communication): New variable "ssize_t sret"; used to
                                store return value from
                                "gnutls_record_recv".  Also cast value
                                from TEMP_FAILURE_RETRY as above.
* plugins.d/usplash.c (usplash_write): New variable "ssize_t sret";
                                       used to store return value from
                                       "write".

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*  -*- coding: utf-8 -*- */
2
2
/*
3
 
 * Usplash - Read a password from usplash and output it
 
3
 * Passprompt - Read a password from usplash and output it
4
4
 * 
5
5
 * Copyright © 2008,2009 Teddy Hogeborn
6
6
 * Copyright © 2008,2009 Björn Påhlsson
42
42
                                   fork(), setuid(), geteuid(),
43
43
                                   setsid(), chdir(), dup2(),
44
44
                                   STDERR_FILENO, execv() */
45
 
#include <stdlib.h>             /* free(), EXIT_FAILURE, realloc(),
46
 
                                   EXIT_SUCCESS, malloc(), _exit() */
 
45
#include <stdlib.h>             /* free(), EXIT_FAILURE, strtoul(),
 
46
                                   realloc(), EXIT_SUCCESS, malloc(),
 
47
                                   _exit() */
47
48
#include <stdlib.h>             /* getenv() */
48
49
#include <dirent.h>             /* opendir(), readdir(), closedir() */
49
 
#include <inttypes.h>           /* intmax_t, strtoimax() */
50
50
#include <sys/stat.h>           /* struct stat, lstat(), S_ISLNK */
51
51
 
52
52
sig_atomic_t interrupted_by_signal = 0;
170
170
    for(struct dirent *proc_ent = readdir(proc_dir);
171
171
        proc_ent != NULL;
172
172
        proc_ent = readdir(proc_dir)){
173
 
      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
      pid_t pid = (pid_t) strtoul(proc_ent->d_name, NULL, 10);
 
174
      if(pid == 0){
 
175
        /* Not a process */
 
176
        continue;
185
177
      }
186
178
      /* Find the executable name by doing readlink() on the
187
179
         /proc/<pid>/exe link */
201
193
        struct stat exe_stat;
202
194
        ret = lstat(exe_link, &exe_stat);
203
195
        if(ret == -1){
204
 
          if(errno == ENOENT){
205
 
            free(exe_link);
206
 
            continue;
207
 
          }
208
196
          perror("lstat");
209
197
          free(exe_link);
210
198
          free(prompt);
220
208
        
221
209
        sret = readlink(exe_link, exe_target, sizeof(exe_target));
222
210
        free(exe_link);
 
211
        if(sret == -1){
 
212
          continue;
 
213
        }
223
214
      }
224
215
      if((sret == ((ssize_t)sizeof(exe_target)-1))
225
216
         and (memcmp(usplash_name, exe_target,
494
485
    /* Child; will become new usplash process */
495
486
    
496
487
    /* Make the effective user ID (root) the only user ID instead of
497
 
       the real user ID (_mandos) */
 
488
       the real user ID (mandos) */
498
489
    ret = setuid(geteuid());
499
490
    if(ret == -1){
500
491
      perror("setuid");