From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: [bug: login] login command with -f flag fails to switch user account.
Date: Sun, 17 Jun 2018 06:22:00 -0000 [thread overview]
Message-ID: <20180617101313.931ffc74f3a6e2ab504b6200@nifty.ne.jp> (raw)
In-Reply-To: <20180614000248.ddf33c4bf1ee219388db1b65@nifty.ne.jp>
[-- Attachment #1: Type: text/plain, Size: 167 bytes --]
Hi Corinna and Yaakov,
I have created a patch against the git head to solve this problem.
Could you please have a look?
--
Takashi Yano <takashi.yano@nifty.ne.jp>
[-- Attachment #2: 0001-Fixed-the-failure-in-the-case-of-trying-to-switch-us.patch --]
[-- Type: application/octet-stream, Size: 2314 bytes --]
From b070bb0f9ced001d3fee40a75a4882ff17d02428 Mon Sep 17 00:00:00 2001
From: Takashi Yano <takashi.yano@nifty.ne.jp>
Date: Sat, 16 Jun 2018 21:59:30 +0900
Subject: [PATCH] Fixed the failure in the case of trying to switch user
account with F flag.
* login.c (main): Use getpwnam_r() instead of getpwnam() to prevent
overwriting the area pointed by pwd by other calls of getpw* family
functions.
* login.c (isROOT_UID): Remove checking SeIncreaseQuotaPrivilege
privilege because account cyg_server created by csih does not have
this privilege.
* winsec.c (getUserInfoForUID): Fix the first argument of the second
NetUserGetInfo() call so that it can check user information locally
if the machine is on a domain.
---
login.c | 9 +++++----
winsec.c | 3 +--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/login.c b/login.c
index 2ddfdcd..271d5e8 100644
--- a/login.c
+++ b/login.c
@@ -91,6 +91,8 @@ static void sleepexit (int eval);
*/
int timeout = 300;
+struct passwd userpwd;
+char pwbuf[16384];
struct passwd *pwd;
int failures;
char term[64], *hostname, *username, *tty;
@@ -213,7 +215,7 @@ main (int argc, char **argv)
}
(void) strcpy (tbuf, username);
#ifdef __CYGWIN__
- pwd = getpwnam (username);
+ getpwnam_r (username, &userpwd, pwbuf, sizeof(pwbuf), &pwd);
#else
if (pwd = getpwnam (username))
salt = pwd->pw_passwd;
@@ -551,10 +553,9 @@ isROOT_UID (uid_t uid)
{
static const char *REQUIRED_PRIVS[] = {
"SeAssignPrimaryTokenPrivilege",
- "SeTcbPrivilege",
- "SeIncreaseQuotaPrivilege"
+ "SeTcbPrivilege"
};
- static const ULONG NUM_REQUIRED_PRIV = 3;
+ static const ULONG NUM_REQUIRED_PRIV = 2;
OSVERSIONINFOEX osvi;
struct passwd *pw;
diff --git a/winsec.c b/winsec.c
index 307a66b..13c5ecf 100644
--- a/winsec.c
+++ b/winsec.c
@@ -978,8 +978,7 @@ getUserInfoForUID (uid_t uid,
/* if we had a domain, then try again locally. if we didn't have a
domain, then the initial call WAS local */
if (NetUserGetInfo
- (*uni_servername, (LPWSTR) & uni_name, level,
- bufptr) != NERR_Success)
+ (NULL, (LPWSTR) & uni_name, level, bufptr) != NERR_Success)
{
syslog (LOG_ERR,
"unable to obtain user info for %s [tried domain controller %s and localhost]\n",
--
2.17.0
[-- Attachment #3: Type: text/plain, Size: 219 bytes --]
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next prev parent reply other threads:[~2018-06-17 1:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 17:01 Takashi Yano
2018-06-17 6:22 ` Takashi Yano [this message]
2018-06-17 22:31 ` Takashi Yano
2018-06-17 22:31 ` Takashi Yano
2018-06-18 14:48 ` Corinna Vinschen
2018-06-19 2:50 ` Yaakov Selkowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180617101313.931ffc74f3a6e2ab504b6200@nifty.ne.jp \
--to=takashi.yano@nifty.ne.jp \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).