/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 dracut-module/password-agent.c

  • Committer: Teddy Hogeborn
  • Date: 2019-07-27 10:11:45 UTC
  • mto: This revision was merged to the branch mainline in revision 384.
  • Revision ID: teddy@recompile.se-20190727101145-jnpbpf8220gldbcd
Add dracut(8) support

Add support for the dracut(8) system for generating initramfs image
files; dracut is an alternative to the "initramfs-tools" package.

* .bzrignore (dracut-module/password-agent): Ignore new binary file.
* dracut-module: New directory for the dracut module.
* INSTALL (Prerequisites/Libraries/Mandos Client): Add dracut as an
                                                   alternative to
                                                   initramfs-tools,
                                                   and also add GLib.
* Makefile (DRACUTMODULE, GLIB_CFLAGS, GLIB_LIBS): New.
  (CPROGS): Add "dracut-module/password-agent".
  (DOCS): Add "dracut-module/password-agent.8mandos".
  (dracut-module/password-agent.8mandos): New.
  (dracut-module/password-agent.8mandos.xhtml): - '' -
  (dracut-module/password-agent): - '' -
  (check): Add command to run tests of password-agent(8mandos).
  (install-client-nokey): Also install the dracut module directory,
                          its files, and the password-agent(8mandos)
                          manual page.
  (install-client): To update the initramfs image file, run
                    update-initramfs or dracut depending on what is
                    installed.
  (uninstall-client): - '' - and also uninstall the the files in the
                      dracut module directory, that directory itself,
                      and the password-agent(8mandos) manual page.
* debian/control (Build-Depends): Add "libglib2.0-dev (>=2.40)".
  (Package: mandos-client/Depends): Add "dracut (>= 044+241-3)" as an
                                    alternative dependency to
                                    initramfs-tools.
  (Package: mandos-client/Conflicts): New; set to
                                      "dracut-config-generic".
  (debian/mandos-client.README.Debian): Document alternative commands
                                        to update the initramfs image
                                        for when dracut is used.
* debian/mandos-client.postinst (update_initramfs): Use alternative
                                                    commands to update
                                                    the initramfs
                                                    image for when
                                                    dracut is used.
* debian/tests/control (password-agent, password-agent-suid): Add two
                                                              new tests.
* dracut-module/ask-password-mandos.path: New.
* dracut-module/ask-password-mandos.service: - '' -
* dracut-module/cmdline-mandos.sh: - '' -
* dracut-module/module-setup.sh: - '' -
* dracut-module/password-agent.c: - '' -
* dracut-module/password-agent.xml: - '' -
* initramfs-unpack: Use the dracut "skipcpio" command, if available.
                    Also be more flexible and try hard to detect where
                    compressed data starts.
* plugins.d/mandos-client.xml (SECURITY): Be more precise that the
                                          mandos-client binary might
                                          not always be setuid, but
                                          that the program assumes
                                          that it has been started
                                          that way.
* plugins.d/password-prompt.c: Add new "--prompt" option.
  (conflict_detection): First try to detect the new PID file of
                        plymouth.
  (main): Define and use new "prompt" variable.
* plugins.d/password-prompt.xml (SYNOPSIS): Show new --prompt option.
  (DESCRIPTION): Describe new behavior of looking for plymouth PID
                 file.
  (OPTIONS): Document new "--prompt" option.
  (ENVIRONMENT): Clarify that the CRYPTTAB_SOURCE and CRYPTTAB_NAME
                 environment variables are not used if the --prompt
                 option is used.  Remove unnecessarily specific
                 details about where the CRYPTTAB_SOURCE and
                 CRYPTTAB_NAME comes from, since this can now be
                 either initramfs-tools or dracut.
  (SEE ALSO): Remove superfluous crypttab(5) reference, and add commas
              to separate the other references.
* plugins.d/plymouth.c: Add new "--prompt" and "--debug" options.
  (debug): New global flag.
  (fprintf_plus): New function, used for debug output.
  (exec_and_wait): Add extra "const" to "argv" argument.
  (main): Define and use new "prompt" variable.  Add debug output.
  (main/options, main/parse_opt): New; used to parse options.
* plugins.d/plymouth.xml (SYNOPSIS): Show new options.
  (OPTIONS): Document new options.
  (ENVIRONMENT): Clarify that the cryptsource and crypttarget
                 environment variables are not used if the --prompt
                 option is used.  Remove unnecessarily specific
                 details about where the cryptsource and crypttarget
                 comes from, since this can now be either
                 initramfs-tools or dracut.
  (EXAMPLE): Add an example using an option.
  (SEE ALSO): Remove superfluous crypttab(5) reference.
* plugins.d/splashy.xml (ENVIRONMENT): Clarify that the cryptsource
                                       and crypttarget environment
                                       variables are not used if the
                                       --prompt option is used.
                                       Remove unnecessarily specific
                                       details about where the
                                       cryptsource and crypttarget
                                       comes from, since this can now
                                       be either initramfs-tools or
                                       dracut.
  (SEE ALSO): Remove superfluous crypttab(5) reference.
* plugins.d/usplash.xml (ENVIRONMENT): Clarify that the cryptsource
                                       and crypttarget environment
                                       variables are not used if the
                                       --prompt option is used.
                                       Remove unnecessarily specific
                                       details about where the
                                       cryptsource and crypttarget
                                       comes from, since this can now
                                       be either initramfs-tools or
                                       dracut.
  (SEE ALSO): Remove superfluous crypttab(5) reference.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1071
1071
  /* "sufficient to read at least one event." - inotify(7) */
1072
1072
  const size_t ievent_size = (sizeof(struct inotify_event)
1073
1073
                              + NAME_MAX + 1);
1074
 
  struct {
1075
 
    struct inotify_event event;
1076
 
    char name_buffer[NAME_MAX + 1];
1077
 
  } ievent_buffer;
1078
 
  struct inotify_event *const ievent = &ievent_buffer.event;
 
1074
  char ievent_buffer[sizeof(struct inotify_event) + NAME_MAX + 1];
 
1075
  struct inotify_event *ievent = ((struct inotify_event *)
 
1076
                                  ievent_buffer);
1079
1077
 
1080
1078
  const ssize_t read_length = read(fd, ievent, ievent_size);
1081
1079
  if(read_length == 0){ /* EOF */
3931
3929
  const size_t ievent_max_size = (sizeof(struct inotify_event)
3932
3930
                                  + NAME_MAX + 1);
3933
3931
  g_assert_cmpint(ievent_max_size, <=, PIPE_BUF);
3934
 
  struct {
3935
 
    struct inotify_event event;
3936
 
    char name_buffer[NAME_MAX + 1];
3937
 
  } ievent_buffer;
3938
 
  struct inotify_event *const ievent = &ievent_buffer.event;
 
3932
  char ievent_buffer[sizeof(struct inotify_event) + NAME_MAX + 1];
 
3933
  struct inotify_event *ievent = ((struct inotify_event *)
 
3934
                                  ievent_buffer);
3939
3935
 
3940
3936
  const char dummy_file_name[] = "ask.dummy_file_name";
3941
3937
  ievent->mask = IN_CLOSE_WRITE;
3943
3939
  memcpy(ievent->name, dummy_file_name, sizeof(dummy_file_name));
3944
3940
  const size_t ievent_size = (sizeof(struct inotify_event)
3945
3941
                              + sizeof(dummy_file_name));
3946
 
  g_assert_cmpint(write(pipefds[1], (char *)ievent, ievent_size),
 
3942
  g_assert_cmpint(write(pipefds[1], ievent_buffer, ievent_size),
3947
3943
                  ==, ievent_size);
3948
3944
  g_assert_cmpint(close(pipefds[1]), ==, 0);
3949
3945
 
4026
4022
  const size_t ievent_max_size = (sizeof(struct inotify_event)
4027
4023
                                  + NAME_MAX + 1);
4028
4024
  g_assert_cmpint(ievent_max_size, <=, PIPE_BUF);
4029
 
  struct {
4030
 
    struct inotify_event event;
4031
 
    char name_buffer[NAME_MAX + 1];
4032
 
  } ievent_buffer;
4033
 
  struct inotify_event *const ievent = &ievent_buffer.event;
 
4025
  char ievent_buffer[sizeof(struct inotify_event) + NAME_MAX + 1];
 
4026
  struct inotify_event *ievent = ((struct inotify_event *)
 
4027
                                  ievent_buffer);
4034
4028
 
4035
4029
  const char dummy_file_name[] = "ask.dummy_file_name";
4036
4030
  ievent->mask = IN_MOVED_TO;
4038
4032
  memcpy(ievent->name, dummy_file_name, sizeof(dummy_file_name));
4039
4033
  const size_t ievent_size = (sizeof(struct inotify_event)
4040
4034
                              + sizeof(dummy_file_name));
4041
 
  g_assert_cmpint(write(pipefds[1], (char *)ievent, ievent_size),
 
4035
  g_assert_cmpint(write(pipefds[1], ievent_buffer, ievent_size),
4042
4036
                  ==, ievent_size);
4043
4037
  g_assert_cmpint(close(pipefds[1]), ==, 0);
4044
4038
 
4123
4117
  const size_t ievent_max_size = (sizeof(struct inotify_event)
4124
4118
                                  + NAME_MAX + 1);
4125
4119
  g_assert_cmpint(ievent_max_size, <=, PIPE_BUF);
4126
 
  struct {
4127
 
    struct inotify_event event;
4128
 
    char name_buffer[NAME_MAX + 1];
4129
 
  } ievent_buffer;
4130
 
  struct inotify_event *const ievent = &ievent_buffer.event;
 
4120
  char ievent_buffer[sizeof(struct inotify_event) + NAME_MAX + 1];
 
4121
  struct inotify_event *ievent = ((struct inotify_event *)
 
4122
                                  ievent_buffer);
4131
4123
 
4132
4124
  const char dummy_file_name[] = "ask.dummy_file_name";
4133
4125
  ievent->mask = IN_DELETE;
4135
4127
  memcpy(ievent->name, dummy_file_name, sizeof(dummy_file_name));
4136
4128
  const size_t ievent_size = (sizeof(struct inotify_event)
4137
4129
                              + sizeof(dummy_file_name));
4138
 
  g_assert_cmpint(write(pipefds[1], (char *)ievent, ievent_size),
 
4130
  g_assert_cmpint(write(pipefds[1], ievent_buffer, ievent_size),
4139
4131
                  ==, ievent_size);
4140
4132
  g_assert_cmpint(close(pipefds[1]), ==, 0);
4141
4133
 
4207
4199
  const size_t ievent_max_size = (sizeof(struct inotify_event)
4208
4200
                                  + NAME_MAX + 1);
4209
4201
  g_assert_cmpint(ievent_max_size, <=, PIPE_BUF);
4210
 
  struct {
4211
 
    struct inotify_event event;
4212
 
    char name_buffer[NAME_MAX + 1];
4213
 
  } ievent_buffer;
4214
 
  struct inotify_event *const ievent = &ievent_buffer.event;
 
4202
  char ievent_buffer[sizeof(struct inotify_event) + NAME_MAX + 1];
 
4203
  struct inotify_event *ievent = ((struct inotify_event *)
 
4204
                                  ievent_buffer);
4215
4205
 
4216
4206
  const char dummy_file_name[] = "ignored.dummy_file_name";
4217
4207
  ievent->mask = IN_CLOSE_WRITE;
4219
4209
  memcpy(ievent->name, dummy_file_name, sizeof(dummy_file_name));
4220
4210
  const size_t ievent_size = (sizeof(struct inotify_event)
4221
4211
                              + sizeof(dummy_file_name));
4222
 
  g_assert_cmpint(write(pipefds[1], (char *)ievent, ievent_size),
 
4212
  g_assert_cmpint(write(pipefds[1], ievent_buffer, ievent_size),
4223
4213
                  ==, ievent_size);
4224
4214
  g_assert_cmpint(close(pipefds[1]), ==, 0);
4225
4215
 
4283
4273
  const size_t ievent_max_size = (sizeof(struct inotify_event)
4284
4274
                                  + NAME_MAX + 1);
4285
4275
  g_assert_cmpint(ievent_max_size, <=, PIPE_BUF);
4286
 
  struct {
4287
 
    struct inotify_event event;
4288
 
    char name_buffer[NAME_MAX + 1];
4289
 
  } ievent_buffer;
4290
 
  struct inotify_event *const ievent = &ievent_buffer.event;
 
4276
  char ievent_buffer[sizeof(struct inotify_event) + NAME_MAX + 1];
 
4277
  struct inotify_event *ievent = ((struct inotify_event *)
 
4278
                                  ievent_buffer);
4291
4279
 
4292
4280
  const char dummy_file_name[] = "ignored.dummy_file_name";
4293
4281
  ievent->mask = IN_MOVED_TO;
4295
4283
  memcpy(ievent->name, dummy_file_name, sizeof(dummy_file_name));
4296
4284
  const size_t ievent_size = (sizeof(struct inotify_event)
4297
4285
                              + sizeof(dummy_file_name));
4298
 
  g_assert_cmpint(write(pipefds[1], (char *)ievent, ievent_size),
 
4286
  g_assert_cmpint(write(pipefds[1], ievent_buffer, ievent_size),
4299
4287
                  ==, ievent_size);
4300
4288
  g_assert_cmpint(close(pipefds[1]), ==, 0);
4301
4289
 
4362
4350
  const size_t ievent_max_size = (sizeof(struct inotify_event)
4363
4351
                                  + NAME_MAX + 1);
4364
4352
  g_assert_cmpint(ievent_max_size, <=, PIPE_BUF);
4365
 
  struct {
4366
 
    struct inotify_event event;
4367
 
    char name_buffer[NAME_MAX + 1];
4368
 
  } ievent_buffer;
4369
 
  struct inotify_event *const ievent = &ievent_buffer.event;
 
4353
  char ievent_buffer[sizeof(struct inotify_event) + NAME_MAX + 1];
 
4354
  struct inotify_event *ievent = ((struct inotify_event *)
 
4355
                                  ievent_buffer);
4370
4356
 
4371
4357
  const char dummy_file_name[] = "ignored.dummy_file_name";
4372
4358
  ievent->mask = IN_DELETE;
4374
4360
  memcpy(ievent->name, dummy_file_name, sizeof(dummy_file_name));
4375
4361
  const size_t ievent_size = (sizeof(struct inotify_event)
4376
4362
                              + sizeof(dummy_file_name));
4377
 
  g_assert_cmpint(write(pipefds[1], (char *)ievent, ievent_size),
 
4363
  g_assert_cmpint(write(pipefds[1], ievent_buffer, ievent_size),
4378
4364
                  ==, ievent_size);
4379
4365
  g_assert_cmpint(close(pipefds[1]), ==, 0);
4380
4366