/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-29 16:35:53 UTC
  • mto: This revision was merged to the branch mainline in revision 384.
  • Revision ID: teddy@recompile.se-20190729163553-1i442i2cbx64c537
Make tests and man page examples match

Make the tests test_manual_page_example[1-5] match exactly what is
written in the manual page, and add comments to manual page as
reminders to keep tests and manual page examples in sync.

* mandos-ctl (Test_commands_from_options.test_manual_page_example_1):
  Remove "--verbose" option, since the manual does not have it as the
  first example, and change assertion to match.
* mandos-ctl.xml (EXAMPLE): Add comments to all examples documenting
  which test function they correspond to.  Also remove unnecessary
  quotes from option arguments in fourth example, and clarify language
  slightly in fifth example.

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