public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
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 22:31:00 -0000	[thread overview]
Message-ID: <20180617124233.6bfc34284a3a8906817fb739@nifty.ne.jp> (raw)
In-Reply-To: <20180617111433.ee3c394532376c2db2c77bbc@nifty.ne.jp>

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

On Sun, 17 Jun 2018 11:14:33 +0900
Takashi Yano <takashi.yano@nifty.ne.jp> wrote:
> Fix typo and wording in commitment message.

Fixed again. Sorry.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

[-- Attachment #2: 0001-Fix-the-issue-that-login-command-with-f-flag-fails-t.patch --]
[-- Type: application/octet-stream, Size: 2426 bytes --]

From b8669c90e017e0b6481cb1ebaa8e9be321fcc0aa 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] Fix the issue that login command with -f flag fails to switch
 user account.

* login.c (main): Use getpwnam_r() instead of getpwnam() to prevent
the area pointed to by pwd from being overwritten by other calls of
getpw*() family functions.
* login.c (isROOT_UID): Remove checking SeIncreaseQuotaPrivilege
privilege because the 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.

Refer to the following post for detail.
https://cygwin.com/ml/cygwin/2018-06/msg00146.html
---
 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

  reply	other threads:[~2018-06-17  3:42 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
2018-06-17 22:31   ` Takashi Yano
2018-06-17 22:31     ` Takashi Yano [this message]
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=20180617124233.6bfc34284a3a8906817fb739@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).