forked from aniani/vim
patch 8.1.0361: remote user not used for completion
Problem: Remote user not used for completion. (Stucki) Solution: Use $USER too. (Dominique Pelle, closes #3407)
This commit is contained in:
73
src/misc1.c
73
src/misc1.c
@@ -4716,6 +4716,25 @@ get_env_name(
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a user name to the list of users in ga_users.
|
||||||
|
* Do nothing if user name is NULL or empty.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
add_user(char_u *user, int need_copy)
|
||||||
|
{
|
||||||
|
char_u *user_copy = (user != NULL && need_copy)
|
||||||
|
? vim_strsave(user) : user;
|
||||||
|
|
||||||
|
if (user_copy == NULL || *user_copy == NUL || ga_grow(&ga_users, 1) == FAIL)
|
||||||
|
{
|
||||||
|
if (need_copy)
|
||||||
|
vim_free(user);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user_copy;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find all user names for user completion.
|
* Find all user names for user completion.
|
||||||
* Done only once and then cached.
|
* Done only once and then cached.
|
||||||
@@ -4733,26 +4752,15 @@ init_users(void)
|
|||||||
|
|
||||||
# if defined(HAVE_GETPWENT) && defined(HAVE_PWD_H)
|
# if defined(HAVE_GETPWENT) && defined(HAVE_PWD_H)
|
||||||
{
|
{
|
||||||
char_u* user;
|
|
||||||
struct passwd* pw;
|
struct passwd* pw;
|
||||||
|
|
||||||
setpwent();
|
setpwent();
|
||||||
while ((pw = getpwent()) != NULL)
|
while ((pw = getpwent()) != NULL)
|
||||||
/* pw->pw_name shouldn't be NULL but just in case... */
|
add_user((char_u *)pw->pw_name, TRUE);
|
||||||
if (pw->pw_name != NULL)
|
|
||||||
{
|
|
||||||
if (ga_grow(&ga_users, 1) == FAIL)
|
|
||||||
break;
|
|
||||||
user = vim_strsave((char_u*)pw->pw_name);
|
|
||||||
if (user == NULL)
|
|
||||||
break;
|
|
||||||
((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user;
|
|
||||||
}
|
|
||||||
endpwent();
|
endpwent();
|
||||||
}
|
}
|
||||||
# elif defined(WIN3264)
|
# elif defined(WIN3264)
|
||||||
{
|
{
|
||||||
char_u* user;
|
|
||||||
DWORD nusers = 0, ntotal = 0, i;
|
DWORD nusers = 0, ntotal = 0, i;
|
||||||
PUSER_INFO_0 uinfo;
|
PUSER_INFO_0 uinfo;
|
||||||
|
|
||||||
@@ -4760,19 +4768,44 @@ init_users(void)
|
|||||||
&nusers, &ntotal, NULL) == NERR_Success)
|
&nusers, &ntotal, NULL) == NERR_Success)
|
||||||
{
|
{
|
||||||
for (i = 0; i < nusers; i++)
|
for (i = 0; i < nusers; i++)
|
||||||
{
|
add_user(utf16_to_enc(uinfo[i].usri0_name, NULL), FALSE);
|
||||||
if (ga_grow(&ga_users, 1) == FAIL)
|
|
||||||
break;
|
|
||||||
user = utf16_to_enc(uinfo[i].usri0_name, NULL);
|
|
||||||
if (user == NULL)
|
|
||||||
break;
|
|
||||||
((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetApiBufferFree(uinfo);
|
NetApiBufferFree(uinfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
# if defined(HAVE_GETPWNAM)
|
||||||
|
{
|
||||||
|
char_u *user_env = mch_getenv((char_u *)"USER");
|
||||||
|
|
||||||
|
// The $USER environment variable may be a valid remote user name (NIS,
|
||||||
|
// LDAP) not already listed by getpwent(), as getpwent() only lists
|
||||||
|
// local user names. If $USER is not already listed, check whether it
|
||||||
|
// is a valid remote user name using getpwnam() and if it is, add it to
|
||||||
|
// the list of user names.
|
||||||
|
|
||||||
|
if (user_env != NULL && *user_env != NUL)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ga_users.ga_len; i++)
|
||||||
|
{
|
||||||
|
char_u *local_user = ((char_u **)ga_users.ga_data)[i];
|
||||||
|
|
||||||
|
if (STRCMP(local_user, user_env) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == ga_users.ga_len)
|
||||||
|
{
|
||||||
|
struct passwd *pw = getpwnam((char *)user_env);
|
||||||
|
|
||||||
|
if (pw != NULL)
|
||||||
|
add_user((char_u *)pw->pw_name, TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -794,6 +794,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
361,
|
||||||
/**/
|
/**/
|
||||||
360,
|
360,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user