krb5: support %{euid} path expansion token

This commit is contained in:
Luke Howard
2018-12-22 16:04:32 +11:00
parent 9d98ce72ff
commit a6ce554c7a
2 changed files with 10 additions and 0 deletions

View File

@@ -299,6 +299,14 @@ _expand_userid(krb5_context context, PTYPE param, const char *postfix, char **st
return 0; return 0;
} }
static krb5_error_code
_expand_euid(krb5_context context, PTYPE param, const char *postfix, char **str)
{
int ret = asprintf(str, "%ld", (unsigned long)geteuid());
if (ret < 0 || *str == NULL)
return krb5_enomem(context);
return 0;
}
#endif /* _WIN32 */ #endif /* _WIN32 */
@@ -366,6 +374,7 @@ static const struct {
{"BINDIR", FTYPE_SPECIAL, 0, BINDIR, _expand_path}, {"BINDIR", FTYPE_SPECIAL, 0, BINDIR, _expand_path},
{"LIBEXEC", FTYPE_SPECIAL, 0, LIBEXECDIR, _expand_path}, {"LIBEXEC", FTYPE_SPECIAL, 0, LIBEXECDIR, _expand_path},
{"SBINDIR", FTYPE_SPECIAL, 0, SBINDIR, _expand_path}, {"SBINDIR", FTYPE_SPECIAL, 0, SBINDIR, _expand_path},
{"euid", SPECIAL(_expand_euid)},
#endif #endif
{"TEMP", SPECIAL(_expand_temp_folder)}, {"TEMP", SPECIAL(_expand_temp_folder)},
{"USERID", SPECIAL(_expand_userid)}, {"USERID", SPECIAL(_expand_userid)},

View File

@@ -294,6 +294,7 @@ struct {
{ "foo", 0, "foo" }, { "foo", 0, "foo" },
{ "foo%}", 0, "foo%}" }, { "foo%}", 0, "foo%}" },
{ "%{uid}", 0, NULL }, { "%{uid}", 0, NULL },
{ "%{euid}", 0, NULL },
{ "foo%{null}", 0, "foo" }, { "foo%{null}", 0, "foo" },
{ "foo%{null}bar", 0, "foobar" }, { "foo%{null}bar", 0, "foobar" },
{ "%{", 1, NULL }, { "%{", 1, NULL },