|
Lines 29-34
Link Here
|
| 29 |
|
29 |
|
| 30 |
#ifdef WITH_SELINUX |
30 |
#ifdef WITH_SELINUX |
| 31 |
#include "log.h" |
31 |
#include "log.h" |
|
|
32 |
#include "xmalloc.h" |
| 32 |
#include "port-linux.h" |
33 |
#include "port-linux.h" |
| 33 |
|
34 |
|
| 34 |
#include <selinux/selinux.h> |
35 |
#include <selinux/selinux.h> |
|
Lines 168-171
ssh_selinux_setup_pty(char *pwname, cons
Link Here
|
| 168 |
freecon(user_ctx); |
169 |
freecon(user_ctx); |
| 169 |
debug3("%s: done", __func__); |
170 |
debug3("%s: done", __func__); |
| 170 |
} |
171 |
} |
|
|
172 |
|
| 173 |
void |
| 174 |
ssh_selinux_change_context(const char *newname) |
| 175 |
{ |
| 176 |
int len, newlen; |
| 177 |
char *oldctx, *newctx, *cx; |
| 178 |
|
| 179 |
if (!ssh_selinux_enabled()) |
| 180 |
return; |
| 181 |
|
| 182 |
if (getcon((security_context_t *)&oldctx) < 0) { |
| 183 |
logit("%s: getcon failed with %s", __func__, strerror (errno)); |
| 184 |
return; |
| 185 |
} |
| 186 |
if ((cx = index(oldctx, ':')) == NULL || (cx = index(cx + 1, ':')) == NULL) { |
| 187 |
logit ("%s: unparseable context %s", __func__, oldctx); |
| 188 |
return; |
| 189 |
} |
| 190 |
|
| 191 |
newlen = strlen(oldctx) + strlen(newname) + 1; |
| 192 |
newctx = xmalloc(newlen); |
| 193 |
len = cx - oldctx + 1; |
| 194 |
memcpy(newctx, oldctx, len); |
| 195 |
strlcpy(newctx + len, newname, newlen - len); |
| 196 |
if ((cx = index(cx + 1, ':'))) |
| 197 |
strlcat(newctx, cx, newlen); |
| 198 |
debug3("%s: setting context from '%s' to '%s'", __func__, oldctx, newctx); |
| 199 |
if (setcon(newctx) < 0) |
| 200 |
logit("%s: setcon failed with %s", __func__, strerror (errno)); |
| 201 |
xfree(oldctx); |
| 202 |
xfree(newctx); |
| 203 |
} |
| 171 |
#endif /* WITH_SELINUX */ |
204 |
#endif /* WITH_SELINUX */ |