[systemd-devel] [PATCH] util: do not execute files without exec permission
Ronny Chevalier
chevalier.ronny at gmail.com
Mon Aug 18 11:47:15 PDT 2014
2014-08-18 15:51 GMT+02:00 Lennart Poettering <lennart at poettering.net>:
> On Sat, 16.08.14 14:24, Ronny Chevalier (chevalier.ronny at gmail.com) wrote:
>
> What's the rationale here? I think it makes a lot of sense to output an
> error if people drop non-executable files in such a directory...
>
Yeah it makes sense. But it is useless to fork & exec() when we know
it will fail so maybe leave the check and add a warning ?
>> ---
>> src/shared/util.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/src/shared/util.c b/src/shared/util.c
>> index 18d40f3..3a03470 100644
>> --- a/src/shared/util.c
>> +++ b/src/shared/util.c
>> @@ -3921,6 +3921,10 @@ void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv
>> _exit(EXIT_FAILURE);
>> }
>>
>> + if (access(path, X_OK) < 0) {
>> + continue;
>> + }
>> +
>> pid = fork();
>> if (pid < 0) {
>> log_error("Failed to fork: %m");
>
>
> Lennart
>
> --
> Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list