/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-08-02 07:19:32 UTC
  • mto: This revision was merged to the branch mainline in revision 386.
  • Revision ID: teddy@recompile.se-20190802071932-wmo43ahs1oejrzlb
Makefile: "pkg-config" is now overrideable by PKG_CONFIG

* Makefile (PKG_CONFIG): New.
  (SYSTEMD, TMPFILES): Use $(PKG_CONFIG) instead of "pkg-config".
  (GNUTLS_CFLAGS, GNUTLS_LIBS, AVAHI_CFLAGS, AVAHI_LIBS): - '' -
  (LIBNL3_CFLAGS, LIBNL3_LIBS, GLIB_CFLAGS, GLIB_LIBS): - '' -

Closes: 933701
Reported-by: Helmut Grohne <helmut@subdivi.de>
Suggested-by: Helmut Grohne <helmut@subdivi.de>
Thanks: Helmut Grohne <helmut@subdivi.de> for bug report and patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
#include <sys/mman.h>           /* munlock(), mlock() */
84
84
#include <fcntl.h>              /* O_CLOEXEC, O_NONBLOCK, fcntl(),
85
85
                                   F_GETFD, F_GETFL, FD_CLOEXEC,
86
 
                                   open(), O_WRONLY, O_NOCTTY,
87
 
                                   O_RDONLY */
 
86
                                   open(), O_WRONLY, O_RDONLY */
88
87
#include <sys/wait.h>           /* waitpid(), WNOHANG, WIFEXITED(),
89
88
                                   WEXITSTATUS() */
90
89
#include <limits.h>             /* PIPE_BUF, NAME_MAX, INT_MAX */
432
431
    case EACCES:
433
432
    case ENAMETOOLONG:
434
433
    case ENOENT:
435
 
    case ENOTDIR:
436
434
      return EX_OSFILE;
437
435
    default:
438
436
      return EX_OSERR;
1019
1017
    return false;
1020
1018
  }
1021
1019
 
1022
 
  if(inotify_add_watch(fd, dir, IN_CLOSE_WRITE | IN_MOVED_TO
1023
 
                       | IN_MOVED_FROM| IN_DELETE | IN_EXCL_UNLINK
1024
 
                       | IN_ONLYDIR)
 
1020
  if(inotify_add_watch(fd, dir, IN_CLOSE_WRITE
 
1021
                       | IN_MOVED_TO | IN_DELETE)
1025
1022
     == -1){
1026
1023
    error(0, errno, "Failed to create inotify watch on %s", dir);
1027
1024
    return false;
1122
1119
             immediately */
1123
1120
          queue->next_run = 1;
1124
1121
        }
1125
 
      } else if(ievent->mask & (IN_MOVED_FROM | IN_DELETE)){
 
1122
      } else if(ievent->mask & IN_DELETE){
1126
1123
        if(not string_set_add(cancelled_filenames,
1127
1124
                              question_filename)){
1128
1125
          error(0, errno, "Could not add question %s to"
2225
2222
 
2226
2223
  {
2227
2224
    __attribute__((cleanup(cleanup_close)))
2228
 
      const int devnull_fd = open("/dev/null",
2229
 
                                  O_WRONLY | O_CLOEXEC | O_NOCTTY);
 
2225
      const int devnull_fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
2230
2226
    g_assert_cmpint(devnull_fd, >=, 0);
2231
2227
    __attribute__((cleanup(cleanup_close)))
2232
2228
      const int real_stderr_fd = dup(STDERR_FILENO);
2256
2252
    {
2257
2253
      __attribute__((cleanup(cleanup_close)))
2258
2254
        const int devnull_fd = open("/dev/null",
2259
 
                                    O_WRONLY | O_CLOEXEC | O_NOCTTY);
 
2255
                                    O_WRONLY | O_CLOEXEC);
2260
2256
      g_assert_cmpint(devnull_fd, >=, 0);
2261
2257
      __attribute__((cleanup(cleanup_close)))
2262
2258
        const int real_stderr_fd = dup(STDERR_FILENO);
2907
2903
 
2908
2904
  __attribute__((cleanup(cleanup_close)))
2909
2905
    const int devnull_fd = open("/dev/null",
2910
 
                                O_WRONLY | O_CLOEXEC | O_NOCTTY);
 
2906
                                O_WRONLY | O_CLOEXEC);
2911
2907
  g_assert_cmpint(devnull_fd, >=, 0);
2912
2908
  __attribute__((cleanup(cleanup_close)))
2913
2909
    const int real_stderr_fd = dup(STDERR_FILENO);
2978
2974
 
2979
2975
  __attribute__((cleanup(cleanup_close)))
2980
2976
    const int devnull_fd = open("/dev/null",
2981
 
                                O_WRONLY | O_CLOEXEC, O_NOCTTY);
 
2977
                                O_WRONLY | O_CLOEXEC);
2982
2978
  g_assert_cmpint(devnull_fd, >=, 0);
2983
2979
  __attribute__((cleanup(cleanup_close)))
2984
2980
    const int real_stderr_fd = dup(STDERR_FILENO);
3022
3018
    buffer password = {};
3023
3019
 
3024
3020
  /* Reading /proc/self/mem from offset 0 will always give EIO */
3025
 
  const int fd = open("/proc/self/mem",
3026
 
                      O_RDONLY | O_CLOEXEC | O_NOCTTY);
 
3021
  const int fd = open("/proc/self/mem", O_RDONLY | O_CLOEXEC);
3027
3022
 
3028
3023
  bool password_is_read = false;
3029
3024
  bool quit_now = false;
3457
3452
  g_assert_cmpuint((unsigned int)queue->length, ==, 0);
3458
3453
}
3459
3454
 
3460
 
static void test_add_inotify_dir_watch_nondir(__attribute__((unused))
3461
 
                                              test_fixture *fixture,
3462
 
                                            __attribute__((unused))
3463
 
                                              gconstpointer
3464
 
                                              user_data){
3465
 
  __attribute__((cleanup(cleanup_close)))
3466
 
    const int epoll_fd = epoll_create1(EPOLL_CLOEXEC);
3467
 
  g_assert_cmpint(epoll_fd, >=, 0);
3468
 
  __attribute__((cleanup(cleanup_queue)))
3469
 
    task_queue *queue = create_queue();
3470
 
  g_assert_nonnull(queue);
3471
 
  __attribute__((cleanup(string_set_clear)))
3472
 
    string_set cancelled_filenames = {};
3473
 
  const mono_microsecs current_time = 0;
3474
 
 
3475
 
  bool quit_now = false;
3476
 
  buffer password = {};
3477
 
  bool mandos_client_exited = false;
3478
 
  bool password_is_read = false;
3479
 
 
3480
 
  const char not_a_directory[] = "/dev/tty";
3481
 
 
3482
 
  FILE *real_stderr = stderr;
3483
 
  FILE *devnull = fopen("/dev/null", "we");
3484
 
  g_assert_nonnull(devnull);
3485
 
  stderr = devnull;
3486
 
  g_assert_false(add_inotify_dir_watch(queue, epoll_fd, &quit_now,
3487
 
                                       &password, not_a_directory,
3488
 
                                       &cancelled_filenames,
3489
 
                                       &current_time,
3490
 
                                       &mandos_client_exited,
3491
 
                                       &password_is_read));
3492
 
  stderr = real_stderr;
3493
 
  g_assert_cmpint(fclose(devnull), ==, 0);
3494
 
 
3495
 
  g_assert_cmpuint((unsigned int)queue->length, ==, 0);
3496
 
}
3497
 
 
3498
3455
static void test_add_inotify_dir_watch_EAGAIN(__attribute__((unused))
3499
3456
                                              test_fixture *fixture,
3500
3457
                                              __attribute__((unused))
3715
3672
}
3716
3673
 
3717
3674
static
3718
 
void test_add_inotify_dir_watch_IN_MOVED_FROM(__attribute__((unused))
3719
 
                                              test_fixture *fixture,
3720
 
                                              __attribute__((unused))
3721
 
                                              gconstpointer
3722
 
                                              user_data){
3723
 
  __attribute__((cleanup(cleanup_close)))
3724
 
    const int epoll_fd = epoll_create1(EPOLL_CLOEXEC);
3725
 
  g_assert_cmpint(epoll_fd, >=, 0);
3726
 
  __attribute__((cleanup(cleanup_queue)))
3727
 
    task_queue *queue = create_queue();
3728
 
  g_assert_nonnull(queue);
3729
 
  __attribute__((cleanup(string_set_clear)))
3730
 
    string_set cancelled_filenames = {};
3731
 
  const mono_microsecs current_time = 0;
3732
 
 
3733
 
  bool quit_now = false;
3734
 
  buffer password = {};
3735
 
  bool mandos_client_exited = false;
3736
 
  bool password_is_read = false;
3737
 
 
3738
 
  __attribute__((cleanup(cleanup_string)))
3739
 
    char *tempdir = make_temporary_directory();
3740
 
  g_assert_nonnull(tempdir);
3741
 
 
3742
 
  __attribute__((cleanup(cleanup_string)))
3743
 
    char *tempfilename = make_temporary_file_in_directory(tempdir);
3744
 
  g_assert_nonnull(tempfilename);
3745
 
 
3746
 
  __attribute__((cleanup(cleanup_string)))
3747
 
    char *targetdir = make_temporary_directory();
3748
 
  g_assert_nonnull(targetdir);
3749
 
 
3750
 
  __attribute__((cleanup(cleanup_string)))
3751
 
    char *targetfilename = NULL;
3752
 
  g_assert_cmpint(asprintf(&targetfilename, "%s/%s", targetdir,
3753
 
                           basename(tempfilename)), >, 0);
3754
 
  g_assert_nonnull(targetfilename);
3755
 
 
3756
 
  g_assert_true(add_inotify_dir_watch(queue, epoll_fd, &quit_now,
3757
 
                                      &password, tempdir,
3758
 
                                      &cancelled_filenames,
3759
 
                                      &current_time,
3760
 
                                      &mandos_client_exited,
3761
 
                                      &password_is_read));
3762
 
 
3763
 
  g_assert_cmpint(rename(tempfilename, targetfilename), ==, 0);
3764
 
 
3765
 
  const task_context *const added_read_task
3766
 
    = find_matching_task(queue,
3767
 
                         (task_context){ .func=read_inotify_event });
3768
 
  g_assert_nonnull(added_read_task);
3769
 
 
3770
 
  /* "sufficient to read at least one event." - inotify(7) */
3771
 
  const size_t ievent_size = (sizeof(struct inotify_event)
3772
 
                              + NAME_MAX + 1);
3773
 
  struct inotify_event *ievent = malloc(ievent_size);
3774
 
  g_assert_nonnull(ievent);
3775
 
 
3776
 
  ssize_t read_size = read(added_read_task->fd, ievent, ievent_size);
3777
 
 
3778
 
  g_assert_cmpint((int)read_size, >, 0);
3779
 
  g_assert_true(ievent->mask & IN_MOVED_FROM);
3780
 
  g_assert_cmpstr(ievent->name, ==, basename(tempfilename));
3781
 
 
3782
 
  free(ievent);
3783
 
 
3784
 
  g_assert_cmpint(unlink(targetfilename), ==, 0);
3785
 
  g_assert_cmpint(rmdir(targetdir), ==, 0);
3786
 
  g_assert_cmpint(rmdir(tempdir), ==, 0);
3787
 
}
3788
 
 
3789
 
static
3790
3675
void test_add_inotify_dir_watch_IN_DELETE(__attribute__((unused))
3791
3676
                                          test_fixture *fixture,
3792
3677
                                          __attribute__((unused))
3850
3735
  g_assert_cmpint(rmdir(tempdir), ==, 0);
3851
3736
}
3852
3737
 
3853
 
static
3854
 
void test_add_inotify_dir_watch_IN_EXCL_UNLINK(__attribute__((unused))
3855
 
                                               test_fixture *fixture,
3856
 
                                               __attribute__((unused))
3857
 
                                               gconstpointer
3858
 
                                               user_data){
3859
 
  __attribute__((cleanup(cleanup_close)))
3860
 
    const int epoll_fd = epoll_create1(EPOLL_CLOEXEC);
3861
 
  g_assert_cmpint(epoll_fd, >=, 0);
3862
 
  __attribute__((cleanup(cleanup_queue)))
3863
 
    task_queue *queue = create_queue();
3864
 
  g_assert_nonnull(queue);
3865
 
  __attribute__((cleanup(string_set_clear)))
3866
 
    string_set cancelled_filenames = {};
3867
 
  const mono_microsecs current_time = 0;
3868
 
 
3869
 
  bool quit_now = false;
3870
 
  buffer password = {};
3871
 
  bool mandos_client_exited = false;
3872
 
  bool password_is_read = false;
3873
 
 
3874
 
  __attribute__((cleanup(cleanup_string)))
3875
 
    char *tempdir = make_temporary_directory();
3876
 
  g_assert_nonnull(tempdir);
3877
 
 
3878
 
  __attribute__((cleanup(cleanup_string)))
3879
 
    char *tempfile = make_temporary_file_in_directory(tempdir);
3880
 
  g_assert_nonnull(tempfile);
3881
 
  int tempfile_fd = open(tempfile, O_WRONLY | O_CLOEXEC | O_NOCTTY
3882
 
                         | O_NOFOLLOW);
3883
 
  g_assert_cmpint(tempfile_fd, >, 2);
3884
 
 
3885
 
  g_assert_true(add_inotify_dir_watch(queue, epoll_fd, &quit_now,
3886
 
                                      &password, tempdir,
3887
 
                                      &cancelled_filenames,
3888
 
                                      &current_time,
3889
 
                                      &mandos_client_exited,
3890
 
                                      &password_is_read));
3891
 
  g_assert_cmpint(unlink(tempfile), ==, 0);
3892
 
 
3893
 
  g_assert_cmpuint((unsigned int)queue->length, >, 0);
3894
 
 
3895
 
  const task_context *const added_read_task
3896
 
    = find_matching_task(queue,
3897
 
                         (task_context){ .func=read_inotify_event });
3898
 
  g_assert_nonnull(added_read_task);
3899
 
 
3900
 
  g_assert_cmpint(added_read_task->fd, >, 2);
3901
 
  g_assert_true(fd_has_cloexec_and_nonblock(added_read_task->fd));
3902
 
 
3903
 
  /* "sufficient to read at least one event." - inotify(7) */
3904
 
  const size_t ievent_size = (sizeof(struct inotify_event)
3905
 
                              + NAME_MAX + 1);
3906
 
  struct inotify_event *ievent = malloc(ievent_size);
3907
 
  g_assert_nonnull(ievent);
3908
 
 
3909
 
  ssize_t read_size = 0;
3910
 
  read_size = read(added_read_task->fd, ievent, ievent_size);
3911
 
 
3912
 
  g_assert_cmpint((int)read_size, >, 0);
3913
 
  g_assert_true(ievent->mask & IN_DELETE);
3914
 
  g_assert_cmpstr(ievent->name, ==, basename(tempfile));
3915
 
 
3916
 
  g_assert_cmpint(close(tempfile_fd), ==, 0);
3917
 
 
3918
 
  /* IN_EXCL_UNLINK should make the closing of the previously unlinked
3919
 
     file not appear as an ievent, so we should not see it now. */
3920
 
  read_size = read(added_read_task->fd, ievent, ievent_size);
3921
 
  g_assert_cmpint((int)read_size, ==, -1);
3922
 
  g_assert_true(errno == EAGAIN);
3923
 
 
3924
 
  free(ievent);
3925
 
 
3926
 
  g_assert_cmpint(rmdir(tempdir), ==, 0);
3927
 
}
3928
 
 
3929
3738
static void test_read_inotify_event_readerror(__attribute__((unused))
3930
3739
                                              test_fixture *fixture,
3931
3740
                                              __attribute__((unused))
3937
3746
  const mono_microsecs current_time = 0;
3938
3747
 
3939
3748
  /* Reading /proc/self/mem from offset 0 will always result in EIO */
3940
 
  const int fd = open("/proc/self/mem",
3941
 
                      O_RDONLY | O_CLOEXEC | O_NOCTTY);
 
3749
  const int fd = open("/proc/self/mem", O_RDONLY | O_CLOEXEC);
3942
3750
 
3943
3751
  bool quit_now = false;
3944
3752
  __attribute__((cleanup(cleanup_queue)))
4296
4104
      }));
4297
4105
}
4298
4106
 
4299
 
static
4300
 
void test_read_inotify_event_IN_MOVED_FROM(__attribute__((unused))
4301
 
                                           test_fixture *fixture,
4302
 
                                           __attribute__((unused))
4303
 
                                           gconstpointer user_data){
4304
 
  __attribute__((cleanup(cleanup_close)))
4305
 
    const int epoll_fd = epoll_create1(EPOLL_CLOEXEC);
4306
 
  g_assert_cmpint(epoll_fd, >=, 0);
4307
 
  __attribute__((cleanup(string_set_clear)))
4308
 
    string_set cancelled_filenames = {};
4309
 
  const mono_microsecs current_time = 0;
4310
 
 
4311
 
  int pipefds[2];
4312
 
  g_assert_cmpint(pipe2(pipefds, O_CLOEXEC | O_NONBLOCK), ==, 0);
4313
 
 
4314
 
  /* "sufficient to read at least one event." - inotify(7) */
4315
 
  const size_t ievent_max_size = (sizeof(struct inotify_event)
4316
 
                                  + NAME_MAX + 1);
4317
 
  g_assert_cmpint(ievent_max_size, <=, PIPE_BUF);
4318
 
  struct {
4319
 
    struct inotify_event event;
4320
 
    char name_buffer[NAME_MAX + 1];
4321
 
  } ievent_buffer;
4322
 
  struct inotify_event *const ievent = &ievent_buffer.event;
4323
 
 
4324
 
  const char dummy_file_name[] = "ask.dummy_file_name";
4325
 
  ievent->mask = IN_MOVED_FROM;
4326
 
  ievent->len = sizeof(dummy_file_name);
4327
 
  memcpy(ievent->name, dummy_file_name, sizeof(dummy_file_name));
4328
 
  const size_t ievent_size = (sizeof(struct inotify_event)
4329
 
                              + sizeof(dummy_file_name));
4330
 
  g_assert_cmpint(write(pipefds[1], (char *)ievent, ievent_size),
4331
 
                  ==, ievent_size);
4332
 
  g_assert_cmpint(close(pipefds[1]), ==, 0);
4333
 
 
4334
 
  bool quit_now = false;
4335
 
  buffer password = {};
4336
 
  bool mandos_client_exited = false;
4337
 
  bool password_is_read = false;
4338
 
  __attribute__((cleanup(cleanup_queue)))
4339
 
    task_queue *queue = create_queue();
4340
 
  g_assert_nonnull(queue);
4341
 
 
4342
 
  task_context task = {
4343
 
    .func=read_inotify_event,
4344
 
    .epoll_fd=epoll_fd,
4345
 
    .fd=pipefds[0],
4346
 
    .quit_now=&quit_now,
4347
 
    .password=&password,
4348
 
    .filename=strdup("/nonexistent"),
4349
 
    .cancelled_filenames=&cancelled_filenames,
4350
 
    .current_time=&current_time,
4351
 
    .mandos_client_exited=&mandos_client_exited,
4352
 
    .password_is_read=&password_is_read,
4353
 
  };
4354
 
  task.func(task, queue);
4355
 
  g_assert_false(quit_now);
4356
 
  g_assert_true(queue->next_run == 0);
4357
 
  g_assert_cmpuint((unsigned int)queue->length, ==, 1);
4358
 
 
4359
 
  g_assert_nonnull(find_matching_task(queue, (task_context){
4360
 
        .func=read_inotify_event,
4361
 
        .epoll_fd=epoll_fd,
4362
 
        .fd=pipefds[0],
4363
 
        .quit_now=&quit_now,
4364
 
        .password=&password,
4365
 
        .filename=task.filename,
4366
 
        .cancelled_filenames=&cancelled_filenames,
4367
 
        .current_time=&current_time,
4368
 
        .mandos_client_exited=&mandos_client_exited,
4369
 
        .password_is_read=&password_is_read,
4370
 
      }));
4371
 
 
4372
 
  g_assert_true(epoll_set_contains(epoll_fd, pipefds[0],
4373
 
                                   EPOLLIN | EPOLLRDHUP));
4374
 
 
4375
 
  __attribute__((cleanup(cleanup_string)))
4376
 
    char *filename = NULL;
4377
 
  g_assert_cmpint(asprintf(&filename, "%s/%s", task.filename,
4378
 
                           dummy_file_name), >, 0);
4379
 
  g_assert_nonnull(filename);
4380
 
  g_assert_true(string_set_contains(*task.cancelled_filenames,
4381
 
                                    filename));
4382
 
}
4383
 
 
4384
4107
static void test_read_inotify_event_IN_DELETE(__attribute__((unused))
4385
4108
                                              test_fixture *fixture,
4386
4109
                                              __attribute__((unused))
4619
4342
                                   EPOLLIN | EPOLLRDHUP));
4620
4343
}
4621
4344
 
4622
 
static void
4623
 
test_read_inotify_event_IN_MOVED_FROM_badname(__attribute__((unused))
4624
 
                                              test_fixture *fixture,
4625
 
                                              __attribute__((unused))
4626
 
                                              gconstpointer
4627
 
                                              user_data){
4628
 
  __attribute__((cleanup(cleanup_close)))
4629
 
    const int epoll_fd = epoll_create1(EPOLL_CLOEXEC);
4630
 
  g_assert_cmpint(epoll_fd, >=, 0);
4631
 
  __attribute__((cleanup(string_set_clear)))
4632
 
    string_set cancelled_filenames = {};
4633
 
  const mono_microsecs current_time = 0;
4634
 
 
4635
 
  int pipefds[2];
4636
 
  g_assert_cmpint(pipe2(pipefds, O_CLOEXEC | O_NONBLOCK), ==, 0);
4637
 
 
4638
 
  /* "sufficient to read at least one event." - inotify(7) */
4639
 
  const size_t ievent_max_size = (sizeof(struct inotify_event)
4640
 
                                  + NAME_MAX + 1);
4641
 
  g_assert_cmpint(ievent_max_size, <=, PIPE_BUF);
4642
 
  struct {
4643
 
    struct inotify_event event;
4644
 
    char name_buffer[NAME_MAX + 1];
4645
 
  } ievent_buffer;
4646
 
  struct inotify_event *const ievent = &ievent_buffer.event;
4647
 
 
4648
 
  const char dummy_file_name[] = "ignored.dummy_file_name";
4649
 
  ievent->mask = IN_MOVED_FROM;
4650
 
  ievent->len = sizeof(dummy_file_name);
4651
 
  memcpy(ievent->name, dummy_file_name, sizeof(dummy_file_name));
4652
 
  const size_t ievent_size = (sizeof(struct inotify_event)
4653
 
                              + sizeof(dummy_file_name));
4654
 
  g_assert_cmpint(write(pipefds[1], (char *)ievent, ievent_size),
4655
 
                  ==, ievent_size);
4656
 
  g_assert_cmpint(close(pipefds[1]), ==, 0);
4657
 
 
4658
 
  bool quit_now = false;
4659
 
  buffer password = {};
4660
 
  bool mandos_client_exited = false;
4661
 
  bool password_is_read = false;
4662
 
  __attribute__((cleanup(cleanup_queue)))
4663
 
    task_queue *queue = create_queue();
4664
 
  g_assert_nonnull(queue);
4665
 
 
4666
 
  task_context task = {
4667
 
    .func=read_inotify_event,
4668
 
    .epoll_fd=epoll_fd,
4669
 
    .fd=pipefds[0],
4670
 
    .quit_now=&quit_now,
4671
 
    .password=&password,
4672
 
    .filename=strdup("/nonexistent"),
4673
 
    .cancelled_filenames=&cancelled_filenames,
4674
 
    .current_time=&current_time,
4675
 
    .mandos_client_exited=&mandos_client_exited,
4676
 
    .password_is_read=&password_is_read,
4677
 
  };
4678
 
  task.func(task, queue);
4679
 
  g_assert_false(quit_now);
4680
 
  g_assert_true(queue->next_run == 0);
4681
 
  g_assert_cmpuint((unsigned int)queue->length, ==, 1);
4682
 
 
4683
 
  g_assert_nonnull(find_matching_task(queue, (task_context){
4684
 
        .func=read_inotify_event,
4685
 
        .epoll_fd=epoll_fd,
4686
 
        .fd=pipefds[0],
4687
 
        .quit_now=&quit_now,
4688
 
        .password=&password,
4689
 
        .filename=task.filename,
4690
 
        .cancelled_filenames=&cancelled_filenames,
4691
 
        .current_time=&current_time,
4692
 
        .mandos_client_exited=&mandos_client_exited,
4693
 
        .password_is_read=&password_is_read,
4694
 
      }));
4695
 
 
4696
 
  g_assert_true(epoll_set_contains(epoll_fd, pipefds[0],
4697
 
                                   EPOLLIN | EPOLLRDHUP));
4698
 
 
4699
 
  __attribute__((cleanup(cleanup_string)))
4700
 
    char *filename = NULL;
4701
 
  g_assert_cmpint(asprintf(&filename, "%s/%s", task.filename,
4702
 
                           dummy_file_name), >, 0);
4703
 
  g_assert_nonnull(filename);
4704
 
  g_assert_false(string_set_contains(cancelled_filenames, filename));
4705
 
}
4706
 
 
4707
4345
static
4708
4346
void test_read_inotify_event_IN_DELETE_badname(__attribute__((unused))
4709
4347
                                               test_fixture *fixture,
5629
5267
                                            __attribute__((unused))
5630
5268
                                            gconstpointer user_data){
5631
5269
  __attribute__((cleanup(cleanup_close)))
5632
 
    const int epoll_fd = open("/dev/null",
5633
 
                              O_WRONLY | O_CLOEXEC | O_NOCTTY);
 
5270
    const int epoll_fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
5634
5271
  __attribute__((cleanup(cleanup_string)))
5635
5272
    char *const question_filename = strdup("/nonexistent/question");
5636
5273
  g_assert_nonnull(question_filename);
6040
5677
                                            __attribute__((unused))
6041
5678
                                            gconstpointer user_data){
6042
5679
  __attribute__((cleanup(cleanup_close)))
6043
 
    const int epoll_fd = open("/dev/null",
6044
 
                              O_WRONLY | O_CLOEXEC | O_NOCTTY);
 
5680
    const int epoll_fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
6045
5681
  __attribute__((cleanup(cleanup_string)))
6046
5682
    char *const question_filename = strdup("/nonexistent/question");
6047
5683
  g_assert_nonnull(question_filename);
6310
5946
                                              const char *const
6311
5947
                                              dirname){
6312
5948
  __attribute__((cleanup(cleanup_close)))
6313
 
    const int devnull_fd = open("/dev/null",
6314
 
                                O_WRONLY | O_CLOEXEC | O_NOCTTY);
 
5949
    const int devnull_fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
6315
5950
  g_assert_cmpint(devnull_fd, >=, 0);
6316
5951
  __attribute__((cleanup(cleanup_close)))
6317
5952
    const int real_stderr_fd = dup(STDERR_FILENO);
7952
7587
              test_add_inotify_dir_watch);
7953
7588
  test_add_st("/task-creators/add_inotify_dir_watch/fail",
7954
7589
              test_add_inotify_dir_watch_fail);
7955
 
  test_add_st("/task-creators/add_inotify_dir_watch/not-a-directory",
7956
 
              test_add_inotify_dir_watch_nondir);
7957
7590
  test_add_st("/task-creators/add_inotify_dir_watch/EAGAIN",
7958
7591
              test_add_inotify_dir_watch_EAGAIN);
7959
7592
  test_add_st("/task-creators/add_inotify_dir_watch/IN_CLOSE_WRITE",
7960
7593
              test_add_inotify_dir_watch_IN_CLOSE_WRITE);
7961
7594
  test_add_st("/task-creators/add_inotify_dir_watch/IN_MOVED_TO",
7962
7595
              test_add_inotify_dir_watch_IN_MOVED_TO);
7963
 
  test_add_st("/task-creators/add_inotify_dir_watch/IN_MOVED_FROM",
7964
 
              test_add_inotify_dir_watch_IN_MOVED_FROM);
7965
 
  test_add_st("/task-creators/add_inotify_dir_watch/IN_EXCL_UNLINK",
7966
 
              test_add_inotify_dir_watch_IN_EXCL_UNLINK);
7967
7596
  test_add_st("/task-creators/add_inotify_dir_watch/IN_DELETE",
7968
7597
              test_add_inotify_dir_watch_IN_DELETE);
7969
7598
  test_add_st("/task/read_inotify_event/readerror",
7978
7607
              test_read_inotify_event_IN_CLOSE_WRITE);
7979
7608
  test_add_st("/task/read_inotify_event/IN_MOVED_TO",
7980
7609
              test_read_inotify_event_IN_MOVED_TO);
7981
 
  test_add_st("/task/read_inotify_event/IN_MOVED_FROM",
7982
 
              test_read_inotify_event_IN_MOVED_FROM);
7983
7610
  test_add_st("/task/read_inotify_event/IN_DELETE",
7984
7611
              test_read_inotify_event_IN_DELETE);
7985
7612
  test_add_st("/task/read_inotify_event/IN_CLOSE_WRITE/badname",
7986
7613
              test_read_inotify_event_IN_CLOSE_WRITE_badname);
7987
7614
  test_add_st("/task/read_inotify_event/IN_MOVED_TO/badname",
7988
7615
              test_read_inotify_event_IN_MOVED_TO_badname);
7989
 
  test_add_st("/task/read_inotify_event/IN_MOVED_FROM/badname",
7990
 
              test_read_inotify_event_IN_MOVED_FROM_badname);
7991
7616
  test_add_st("/task/read_inotify_event/IN_DELETE/badname",
7992
7617
              test_read_inotify_event_IN_DELETE_badname);
7993
7618
  test_add_st("/task/open_and_parse_question/ENOENT",