Show More
@@ -127,21 +127,25 b' static void preparesockdir(const char *s' | |||||
127 | abortmsg("insecure sockdir %s", sockdir); |
|
127 | abortmsg("insecure sockdir %s", sockdir); | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
|
130 | static void getdefaultsockdir(char sockdir[], size_t size) | |||
|
131 | { | |||
|
132 | /* by default, put socket file in secure directory | |||
|
133 | * (permission of socket file may be ignored on some Unices) */ | |||
|
134 | const char *tmpdir = getenv("TMPDIR"); | |||
|
135 | if (!tmpdir) | |||
|
136 | tmpdir = "/tmp"; | |||
|
137 | int r = snprintf(sockdir, size, "%s/chg%d", tmpdir, geteuid()); | |||
|
138 | if (r < 0 || (size_t)r >= size) | |||
|
139 | abortmsg("too long TMPDIR (r = %d)", r); | |||
|
140 | } | |||
|
141 | ||||
130 | static void setcmdserveropts(struct cmdserveropts *opts) |
|
142 | static void setcmdserveropts(struct cmdserveropts *opts) | |
131 | { |
|
143 | { | |
132 | int r; |
|
144 | int r; | |
133 | char sockdir[PATH_MAX]; |
|
145 | char sockdir[PATH_MAX]; | |
134 | const char *envsockname = getenv("CHGSOCKNAME"); |
|
146 | const char *envsockname = getenv("CHGSOCKNAME"); | |
135 | if (!envsockname) { |
|
147 | if (!envsockname) { | |
136 | /* by default, put socket file in secure directory |
|
148 | getdefaultsockdir(sockdir, sizeof(sockdir)); | |
137 | * (permission of socket file may be ignored on some Unices) */ |
|
|||
138 | const char *tmpdir = getenv("TMPDIR"); |
|
|||
139 | if (!tmpdir) |
|
|||
140 | tmpdir = "/tmp"; |
|
|||
141 | r = snprintf(sockdir, sizeof(sockdir), "%s/chg%d", |
|
|||
142 | tmpdir, geteuid()); |
|
|||
143 | if (r < 0 || (size_t)r >= sizeof(sockdir)) |
|
|||
144 | abortmsg("too long TMPDIR (r = %d)", r); |
|
|||
145 | preparesockdir(sockdir); |
|
149 | preparesockdir(sockdir); | |
146 | } |
|
150 | } | |
147 |
|
151 |
General Comments 0
You need to be logged in to leave comments.
Login now