Use roken_get_loginname() when we want getlogin_r()
This commit is contained in:

committed by
Nico Williams

parent
d02277b45f
commit
c9b5a4df90
@@ -370,10 +370,13 @@ _kadm5_c_get_cred_cache(krb5_context context,
|
|||||||
* determine the client from a credentials cache.
|
* determine the client from a credentials cache.
|
||||||
*/
|
*/
|
||||||
char userbuf[128];
|
char userbuf[128];
|
||||||
const char *user;
|
const char *user = NULL;
|
||||||
|
|
||||||
user = roken_get_username(userbuf, sizeof(userbuf));
|
if (geteuid() == 0)
|
||||||
if(user == NULL) {
|
user = roken_get_loginname(userbuf, sizeof(userbuf));
|
||||||
|
if (user == NULL)
|
||||||
|
user = roken_get_username(userbuf, sizeof(userbuf));
|
||||||
|
if (user == NULL) {
|
||||||
krb5_set_error_message(context, KADM5_FAILURE, "Unable to find local user name");
|
krb5_set_error_message(context, KADM5_FAILURE, "Unable to find local user name");
|
||||||
return KADM5_FAILURE;
|
return KADM5_FAILURE;
|
||||||
}
|
}
|
||||||
|
@@ -41,18 +41,22 @@ KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
|||||||
_krb5_get_default_principal_local (krb5_context context,
|
_krb5_get_default_principal_local (krb5_context context,
|
||||||
krb5_principal *princ)
|
krb5_principal *princ)
|
||||||
{
|
{
|
||||||
const char *user;
|
const char *user = NULL;
|
||||||
const char *second_component = NULL;
|
const char *second_component = NULL;
|
||||||
char userbuf[128];
|
char userbuf[128];
|
||||||
|
|
||||||
*princ = NULL;
|
*princ = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: We depend on roken_get_username() preferentially using
|
* NOTE: We prefer getlogin_r() (via roken_get_loginname()) to using $USER,
|
||||||
* getlogin_r() first when !issuid() && getuid() == 0, otherwise we
|
* $LOGNAME, or getpwuid_r() (via roken_get_username()), in that
|
||||||
* won't figure out to output <username>/root@DEFAULT_REALM.
|
* order, otherwise we won't figure out to output
|
||||||
|
* <username>/root@DEFAULT_REALM.
|
||||||
*/
|
*/
|
||||||
user = roken_get_username(userbuf, sizeof(userbuf));
|
if (geteuid() == 0)
|
||||||
|
user = roken_get_loginname(userbuf, sizeof(userbuf));
|
||||||
|
if (user == NULL)
|
||||||
|
user = roken_get_username(userbuf, sizeof(userbuf));
|
||||||
if (user == NULL) {
|
if (user == NULL) {
|
||||||
krb5_set_error_message(context, ENOTTY,
|
krb5_set_error_message(context, ENOTTY,
|
||||||
N_("unable to figure out current principal",
|
N_("unable to figure out current principal",
|
||||||
|
Reference in New Issue
Block a user