From: Yu Watanabe Date: Tue, 15 May 2018 13:53:19 +0000 (+0900) Subject: timedate: do not copy input string before bus_verify_polkit_async() X-Git-Tag: v239~249^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=539a68e0fb719a32560d648df8d4d158afeaaf02;p=platform%2Fupstream%2Fsystemd.git timedate: do not copy input string before bus_verify_polkit_async() This fixes the commit 2c3def62144c9d689ddda88a866b1e623074eaae which breaks `timedatectl set-timezone` called by non-privileged user. --- diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 6928bb9..1f161d4 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -545,10 +545,7 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error * if (!timezone_is_valid(z, LOG_DEBUG)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid time zone '%s'", z); - r = free_and_strdup(&c->zone, z); - if (r < 0) - return r; - if (r == 0) + if (streq_ptr(z, c->zone)) return sd_bus_reply_method_return(m, NULL); r = bus_verify_polkit_async( @@ -565,6 +562,10 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error * if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ + r = free_and_strdup(&c->zone, z); + if (r < 0) + return r; + /* 1. Write new configuration file */ r = context_write_data_timezone(c); if (r < 0) {