/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-02-13 05:38:21 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090213053821-03e696gckk4nbjps
Support not using IPv6 in server:

* mandos (AvahiService.__init__): Take new "protocol" parameter.  All
                                  callers changed.
  (IPv6_TCPServer.__init__): Take new "use_ipv6" parameter.  All
                             callers changed.
  (IPv6_TCPServer.server_bind): Create IPv4 socket if not using IPv6.
  (main): New "--no-ipv6" command line option.  New "use_ipv6" config
          option.
* mandos-options.xml ([@id="address"]): Document conditional IPv4
                                        address support.
  ([@id="ipv6"]): New paragraph.
* mandos.conf (use_ipv6): New config option.
* mandos.conf.xml (OPTIONS): Document new "use_dbus" option.
  (EXAMPLE): Changed to use IPv6 link-local address.  Added "use_ipv6"
             option.
* mandos.xml (SYNOPSIS): New "--no-ipv6" option.
  (OPTIONS): Document new "--no-ipv6" option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*  -*- coding: utf-8 -*- */
2
2
/*
3
 
 * Passprompt - Read a password from usplash and output it
 
3
 * Usplash - 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, strtoul(),
46
 
                                   realloc(), EXIT_SUCCESS, malloc(),
47
 
                                   _exit() */
 
45
#include <stdlib.h>             /* free(), EXIT_FAILURE, realloc(),
 
46
                                   EXIT_SUCCESS, malloc(), _exit() */
48
47
#include <stdlib.h>             /* getenv() */
49
48
#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 = (pid_t) strtoul(proc_ent->d_name, NULL, 10);
174
 
      if(pid == 0){
175
 
        /* Not a process */
176
 
        continue;
 
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;
177
185
      }
178
186
      /* Find the executable name by doing readlink() on the
179
187
         /proc/<pid>/exe link */
193
201
        struct stat exe_stat;
194
202
        ret = lstat(exe_link, &exe_stat);
195
203
        if(ret == -1){
 
204
          if(errno == ENOENT){
 
205
            free(exe_link);
 
206
            continue;
 
207
          }
196
208
          perror("lstat");
197
209
          free(exe_link);
198
210
          free(prompt);
208
220
        
209
221
        sret = readlink(exe_link, exe_target, sizeof(exe_target));
210
222
        free(exe_link);
211
 
        if(sret == -1){
212
 
          continue;
213
 
        }
214
223
      }
215
224
      if((sret == ((ssize_t)sizeof(exe_target)-1))
216
225
         and (memcmp(usplash_name, exe_target,
485
494
    /* Child; will become new usplash process */
486
495
    
487
496
    /* Make the effective user ID (root) the only user ID instead of
488
 
       the real user ID (mandos) */
 
497
       the real user ID (_mandos) */
489
498
    ret = setuid(geteuid());
490
499
    if(ret == -1){
491
500
      perror("setuid");