diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2016-02-11 13:29:53 +0100 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2016-02-11 13:29:53 +0100 |
commit | c8385ece1e3d7207b3898474925d53e9a656c9b5 (patch) | |
tree | 8d42544c8b724874b348c815f636c7132fa66fe2 /src/core/automount.c | |
parent | cf92d86020fea4987040d1c4c1da5126a9d3cf7a (diff) | |
parent | e903182e5b0daa941de47a9c08c824106cec7fe0 (diff) |
Merge pull request #2576 from poettering/random-fixes
Random fixes
Diffstat (limited to 'src/core/automount.c')
-rw-r--r-- | src/core/automount.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/core/automount.c b/src/core/automount.c index 772ec222ca..5dc6fd98e7 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -726,7 +726,15 @@ static void automount_enter_runnning(Automount *a) { if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id) log_unit_info(UNIT(a), "Automount point already active?"); else { - r = manager_add_job(UNIT(a)->manager, JOB_START, UNIT_TRIGGER(UNIT(a)), JOB_REPLACE, &error, NULL); + Unit *trigger; + + trigger = UNIT_TRIGGER(UNIT(a)); + if (!trigger) { + log_unit_error(UNIT(a), "Unit to trigger vanished."); + goto fail; + } + + r = manager_add_job(UNIT(a)->manager, JOB_START, trigger, JOB_REPLACE, &error, NULL); if (r < 0) { log_unit_warning(UNIT(a), "Failed to queue mount startup job: %s", bus_error_message(&error, r)); goto fail; @@ -742,6 +750,7 @@ fail: static int automount_start(Unit *u) { Automount *a = AUTOMOUNT(u); + Unit *trigger; assert(a); assert(a->state == AUTOMOUNT_DEAD || a->state == AUTOMOUNT_FAILED); @@ -751,8 +760,11 @@ static int automount_start(Unit *u) { return -EEXIST; } - if (UNIT_TRIGGER(u)->load_state != UNIT_LOADED) + trigger = UNIT_TRIGGER(u); + if (!trigger || trigger->load_state != UNIT_LOADED) { + log_unit_error(u, "Refusing to start, unit to trigger not loaded."); return -ENOENT; + } a->result = AUTOMOUNT_SUCCESS; automount_enter_waiting(a); @@ -899,6 +911,7 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo union autofs_v5_packet_union packet; Automount *a = AUTOMOUNT(userdata); struct stat st; + Unit *trigger; int r; assert(a); @@ -971,7 +984,13 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo break; } - r = manager_add_job(UNIT(a)->manager, JOB_STOP, UNIT_TRIGGER(UNIT(a)), JOB_REPLACE, &error, NULL); + trigger = UNIT_TRIGGER(UNIT(a)); + if (!trigger) { + log_unit_error(UNIT(a), "Unit to trigger vanished."); + goto fail; + } + + r = manager_add_job(UNIT(a)->manager, JOB_STOP, trigger, JOB_REPLACE, &error, NULL); if (r < 0) { log_unit_warning(UNIT(a), "Failed to queue umount startup job: %s", bus_error_message(&error, r)); goto fail; |