1 |
jpp |
1.1 |
diff -up ./plugins/sudoers/iolog.c.iologracecondition ./plugins/sudoers/iolog.c |
2 |
|
|
--- ./plugins/sudoers/iolog.c.iologracecondition 2016-10-06 18:09:37.226616830 +0200 |
3 |
|
|
+++ ./plugins/sudoers/iolog.c 2016-10-06 18:20:28.930151862 +0200 |
4 |
|
|
@@ -118,11 +118,15 @@ mkdir_parents(char *path) |
5 |
|
|
if ((slash = strchr(slash + 1, '/')) == NULL) |
6 |
|
|
break; |
7 |
|
|
*slash = '\0'; |
8 |
|
|
- if (stat(path, &sb) != 0) { |
9 |
|
|
- if (mkdir(path, S_IRWXU) != 0) |
10 |
|
|
+ if (mkdir(path, S_IRWXU) != 0) { |
11 |
|
|
+ int mkdir_errno = errno; |
12 |
|
|
+ if (stat(path, &sb)) { |
13 |
|
|
+ errno = mkdir_errno; |
14 |
|
|
log_fatal(USE_ERRNO, _("unable to mkdir %s"), path); |
15 |
|
|
- } else if (!S_ISDIR(sb.st_mode)) { |
16 |
|
|
- log_fatal(0, _("%s: %s"), path, strerror(ENOTDIR)); |
17 |
|
|
+ } |
18 |
|
|
+ if (!S_ISDIR(sb.st_mode)) { |
19 |
|
|
+ log_fatal(0, _("%s: %s"), path, strerror(ENOTDIR)); |
20 |
|
|
+ } |
21 |
|
|
} |
22 |
|
|
*slash = '/'; |
23 |
|
|
} |
24 |
|
|
@@ -151,12 +155,16 @@ io_nextid(char *iolog_dir, char *iolog_d |
25 |
|
|
* Create I/O log directory if it doesn't already exist. |
26 |
|
|
*/ |
27 |
|
|
mkdir_parents(iolog_dir); |
28 |
|
|
- if (stat(iolog_dir, &sb) != 0) { |
29 |
|
|
- if (mkdir(iolog_dir, S_IRWXU) != 0) |
30 |
|
|
- log_fatal(USE_ERRNO, _("unable to mkdir %s"), iolog_dir); |
31 |
|
|
- } else if (!S_ISDIR(sb.st_mode)) { |
32 |
|
|
- log_fatal(0, _("%s exists but is not a directory (0%o)"), |
33 |
|
|
+ if (mkdir(iolog_dir, S_IRWXU) != 0) { |
34 |
|
|
+ int mkdir_errno = errno; |
35 |
|
|
+ if (stat(iolog_dir, &sb)) { |
36 |
|
|
+ errno = mkdir_errno; |
37 |
|
|
+ log_fatal(USE_ERRNO, _("unable to mkdir %s"), iolog_dir); |
38 |
|
|
+ } |
39 |
|
|
+ if (!S_ISDIR(sb.st_mode)) { |
40 |
|
|
+ log_fatal(0, _("%s exists but is not a directory (0%o)"), |
41 |
|
|
iolog_dir, (unsigned int) sb.st_mode); |
42 |
|
|
+ } |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
/* |