/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to plugins.d/splashy.c

  • Committer: Teddy Hogeborn
  • Date: 2019-03-30 07:03:04 UTC
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190330070304-dqgch62lsaaygg46
mandos-ctl: Refactor D-Bus operations

* mandos-ctl (dbus): Rename imported module to "dbus_python".
  (main): Only create a bus object and do everything via that object.
  (get_mandos_dbus_object): Remove and move code into dbus or
                            dbus_python_adapter namespaces.
  (if_dbus_exception_log_with_exception_and_exit): - '' -
  (SilenceLogger): - '' -
  (dbus): New; move everything dbus-specific into this module-like
          namespace.
  (dbus_python_adapter): New; move everything specific to the
                         dbus-python D-Bus module into this
                         module-like namespace.
  (command.Base.run): Take only a bus argument; use only that.  Pass
                      "client" argument as a D-Bus object path string,
                      not a dbus-python proxy object.  All derivatives
                      adjusted.
  (command.IsEnabled.is_enabled): Remove.
  (command.Approve, command.Deny, command.Remove,
  command.PropertySetter): Do no logging of D-Bus commands, and use
  only bus, not client, to do D-Bus calls.
  (command.DumpJSON.dbus_boolean_to_bool): Remove; move filtering to
                                           dbus_python_adapter.
  (command.Enable, command.Disable, command.StopChecker,
  command.ApproveByDefault): Use normal Python booleans instead of
  dbus-python's special Boolean types.
  (Unique): New; move here out from inside TestPropertySetterCmd.
  (Test_get_mandos_dbus_object): Remove.
  (Test_get_managed_objects): - '' -
  (Test_dbus_exceptions): New.
  (Test_dbus_MandosBus): - '' -
  (Test_dbus_python_adapter_SystemBus): - '' -
  (Test_dbus_python_adapter_CachingBus): - '' -
  (Test_commands_from_options): Don't create mock client proxy
  objects, define dict of client properties and use a mock dbus to
  verify that the correct D-Bus calls are made.  Also remove any types
  specific to dbus-python.
  (TestEnableCmd, TestDisableCmd, TestStartCheckerCmd,
  TestStopCheckerCmd, TestApproveByDefaultCmd, TestDenyByDefaultCmd):
  Use normal Python booleans instead of dbus-python's special Boolean
  types.
  (TestPropertySetterValueCmd.runTest): Remove; unnecessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/*
3
3
 * Splashy - Read a password from splashy and output it
4
4
 * 
5
 
 * Copyright © 2008-2018, 2021-2022 Teddy Hogeborn
6
 
 * Copyright © 2008-2018, 2021-2022 Björn Påhlsson
 
5
 * Copyright © 2008-2018 Teddy Hogeborn
 
6
 * Copyright © 2008-2018 Björn Påhlsson
7
7
 * 
8
8
 * This file is part of Mandos.
9
9
 * 
23
23
 * Contact the authors at <mandos@recompile.se>.
24
24
 */
25
25
 
26
 
#define _GNU_SOURCE             /* vasprintf(),
27
 
                                   program_invocation_short_name,
28
 
                                   asprintf(), TEMP_FAILURE_RETRY() */
29
 
#include <sys/types.h>          /* sig_atomic_t, pid_t, setuid(),
30
 
                                   geteuid(), setsid() */
31
 
#include <stdarg.h>             /* va_list, va_start(), vfprintf() */
32
 
#include <stdio.h>              /* vasprintf(), fprintf(), stderr,
33
 
                                   vfprintf(), asprintf() */
34
 
#include <errno.h>              /* program_invocation_short_name,
35
 
                                   errno, EACCES, ENOTDIR, ELOOP,
 
26
#define _GNU_SOURCE             /* TEMP_FAILURE_RETRY(), asprintf() */
 
27
#include <signal.h>             /* sig_atomic_t, struct sigaction,
 
28
                                   sigemptyset(), sigaddset(), SIGINT,
 
29
                                   SIGHUP, SIGTERM, sigaction,
 
30
                                   SIG_IGN, kill(), SIGKILL */
 
31
#include <stddef.h>             /* NULL */
 
32
#include <stdlib.h>             /* getenv() */
 
33
#include <stdio.h>              /* asprintf(), vasprintf(), vprintf(),
 
34
                                   fprintf() */
 
35
#include <stdlib.h>             /* EXIT_FAILURE, free(),
 
36
                                   EXIT_SUCCESS */
 
37
#include <sys/types.h>          /* pid_t, DIR, struct dirent,
 
38
                                   ssize_t */
 
39
#include <dirent.h>             /* opendir(), readdir(), closedir() */
 
40
#include <inttypes.h>           /* intmax_t, strtoimax() */
 
41
#include <sys/stat.h>           /* struct stat, lstat(), S_ISLNK */
 
42
#include <iso646.h>             /* not, or, and */
 
43
#include <unistd.h>             /* readlink(), fork(), execl(),
 
44
                                   sleep(), dup2() STDERR_FILENO,
 
45
                                   STDOUT_FILENO, _exit(),
 
46
                                   pause() */
 
47
#include <string.h>             /* memcmp(), strerror() */
 
48
#include <errno.h>              /* errno, EACCES, ENOTDIR, ELOOP,
36
49
                                   ENOENT, ENAMETOOLONG, EMFILE,
37
50
                                   ENFILE, ENOMEM, ENOEXEC, EINVAL,
38
51
                                   E2BIG, EFAULT, EIO, ETXTBSY,
39
52
                                   EISDIR, ELIBBAD, EPERM, EINTR,
40
53
                                   ECHILD */
41
 
#include <string.h>             /* strerror(), memcmp() */
42
54
#include <error.h>              /* error() */
43
 
#include <stdlib.h>             /* free(), EXIT_FAILURE, getenv(),
44
 
                                   EXIT_SUCCESS, abort() */
45
 
#include <stddef.h>             /* NULL */
46
 
#include <dirent.h>             /* DIR, opendir(), struct dirent,
47
 
                                   readdir(), closedir() */
 
55
#include <sys/wait.h>           /* waitpid(), WIFEXITED(),
 
56
                                   WEXITSTATUS() */
48
57
#include <sysexits.h>           /* EX_OSERR, EX_OSFILE,
49
58
                                   EX_UNAVAILABLE */
50
 
#include <inttypes.h>           /* intmax_t, strtoimax() */
51
 
#include <iso646.h>             /* or, not, and */
52
 
#include <unistd.h>             /* ssize_t, readlink(), fork(),
53
 
                                   execl(), _exit(),
54
 
                                   TEMP_FAILURE_RETRY(), sleep(),
55
 
                                   setuid(), geteuid(), setsid(),
56
 
                                   chdir(), dup2(), STDERR_FILENO,
57
 
                                   STDOUT_FILENO, pause() */
58
 
#include <sys/stat.h>           /* struct stat, lstat(), S_ISLNK() */
59
 
#include <signal.h>             /* struct sigaction, sigemptyset(),
60
 
                                   sigaddset(), SIGINT, SIGHUP,
61
 
                                   SIGTERM, SIG_IGN, kill(), SIGKILL,
62
 
                                   SIG_DFL, raise() */
63
 
#include <sys/wait.h>           /* waitpid(), WIFEXITED(),
64
 
                                   WEXITSTATUS() */
 
59
#include <stdarg.h>             /* va_list, va_start(), ... */
65
60
 
66
61
sig_atomic_t interrupted_by_signal = 0;
67
62
int signal_received;