Show More
@@ -130,11 +130,18 b' static void preparesockdir(const char *s' | |||||
130 | static void getdefaultsockdir(char sockdir[], size_t size) |
|
130 | static void getdefaultsockdir(char sockdir[], size_t size) | |
131 | { |
|
131 | { | |
132 | /* by default, put socket file in secure directory |
|
132 | /* by default, put socket file in secure directory | |
|
133 | * (${XDG_RUNTIME_DIR}/chg, or /${TMPDIR:-tmp}/chg$UID) | |||
133 | * (permission of socket file may be ignored on some Unices) */ |
|
134 | * (permission of socket file may be ignored on some Unices) */ | |
134 |
const char * |
|
135 | const char *runtimedir = getenv("XDG_RUNTIME_DIR"); | |
135 | if (!tmpdir) |
|
136 | int r; | |
136 | tmpdir = "/tmp"; |
|
137 | if (runtimedir) { | |
137 |
|
|
138 | r = snprintf(sockdir, size, "%s/chg", runtimedir); | |
|
139 | } else { | |||
|
140 | const char *tmpdir = getenv("TMPDIR"); | |||
|
141 | if (!tmpdir) | |||
|
142 | tmpdir = "/tmp"; | |||
|
143 | r = snprintf(sockdir, size, "%s/chg%d", tmpdir, geteuid()); | |||
|
144 | } | |||
138 | if (r < 0 || (size_t)r >= size) |
|
145 | if (r < 0 || (size_t)r >= size) | |
139 | abortmsg("too long TMPDIR (r = %d)", r); |
|
146 | abortmsg("too long TMPDIR (r = %d)", r); | |
140 | } |
|
147 | } |
General Comments 0
You need to be logged in to leave comments.
Login now