From patchwork Mon Jan 20 20:41:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 13945511 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 154C31E9900 for ; Mon, 20 Jan 2025 20:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737405733; cv=none; b=s3gzYC5ElfaPnJPU/Bn5jQzfaaVHP9+XPJBvNnGWKIax3EfzXJx+8ic8Mtg3fnMxG+rlgKk6PaKOANwTprRefl5JwTTTaq2Ywh0a1/QMcNnhE2r/cRvm/RBYE0/fyZU5zcNI3vz+mpsE5r+NV1LDAGh4NB61hDbXNqFzZV6vnCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737405733; c=relaxed/simple; bh=wUJMonHW6WPVHgSAPev4mTrKWpGGGsHx+tZ3dDVFhTU=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=DNa5zkpl8octdbJWwQXD7R+Z9rurtM1zVcdEnJN1FcV3bYVidlwirtPDqkl8eRk9zQimc/rrG/waPXCfjePzqUvtqY8DhUwZRlmG5MVu9rGJVxoPxOC+1YuHjrgBG37os3vLVAwuLEErGxCVyT4DeVWxb5MIlSt76Dvmja5T/e0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RvXJayom; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RvXJayom" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-5401bd6cdb7so4696538e87.2 for ; Mon, 20 Jan 2025 12:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737405728; x=1738010528; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=ZY7qXD284mURJ17DtcDbdwdZv+VVWgfUdLkjIOPslkA=; b=RvXJayomqIQLjVCQBu2mwvM5eGEmGt7XCkXKJT/U3rMvfGv59vrR3ymP6SJHhEE/v5 WyWhMLJpXOA0p1SSoAaCUrZVKLKqD/NV3Z9kcRow0Hn6iCCKtzjflnSXH/oQnA3xMjlw R7mcIQuId/0aFumXxO6aDry8/iKs9b4aH1N+QYYr+Ktc3cdDVoM1WH110gA+G6VtTjHf iVeZw5gqWXIUCyxXstOZC+zt/VB+LOFn8XvOWOCMYtwGH3DpM69OglpTOtgMLzTWej0v /pEbfcFqZKQx7sFANM8NGy6Wzju52ImIjWyCoJNrhWBLBC1SkjmsLvalCV8ovMt6FJUa sWWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737405728; x=1738010528; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZY7qXD284mURJ17DtcDbdwdZv+VVWgfUdLkjIOPslkA=; b=MpTD8CHrw/fm2h0Y4PExayGS0xB+MECHP1IUvCJBNuE1MBMuiL9/iK1nGDQED1yKQt R1wmCMBU0FbYDEvU0JJkTOjsko2K7VN+lcV3/1H15ybcPe9higiSdUu5Y6jFOhxc2N+p N76Fb0nqZqAiUr36cgX79rXEtkVeMElVkp3zXelo02qrLOO9T7Neq7DmkXiHdXBiELHV VBmCdSZBoNamTT9wyj/M2K2XhNtc42/weDGBESc5xmt24aNFso7MBZ0y79YLeRUO/bqh 5mFu1rXC1cUeTBWHEgHCkAGtd9PWoT7DIyl3dVZiyCFDwLzdWELArRflR11Eh2Bd2eNk 5rtg== X-Forwarded-Encrypted: i=1; AJvYcCWahkNXSd12bir7s39/q/1wyDHT+VVUphZs7e4Nb+8dEU2sSj89M+SF1LFwcSsBx3GNo0tjNvLnKQuf@vger.kernel.org X-Gm-Message-State: AOJu0YzWFH849mZ3JGKq0I2eecjFWGLkirmX2slJ11xUUzKxB2zz4qEr aho424zLSIWaNFGZ2MFFAZ9FP5z7FSI3n0XwL4fI6cUJEmeVCLNcfrAxUtXE7d6Q+v2LghJP+7b AmvkX+RUxXYzSgQfvGoDEDpyAfFg= X-Gm-Gg: ASbGncv1WYUWpa9RkX27u8kSQ6pTLPBpxadOPhiko2Rg74O30lJ8JCCYC+3HljMK65h sAuDDAip8D4l/HpEorEd+r5xEhSkz3/6IC3GHHdED3B5aQmEOhbg= X-Google-Smtp-Source: AGHT+IGhYCMjhAM/+ZHIf3vX2+/WDNpKFxRnNc99+gQtdbxxX2aNtXzT6WJxoY8Zn2Q6GgGPME2lR48zlfPAVWTbmxg= X-Received: by 2002:a05:6512:3409:b0:540:20eb:80c5 with SMTP id 2adb3069b0e04-5439c268000mr5460087e87.37.1737405727759; Mon, 20 Jan 2025 12:42:07 -0800 (PST) Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Steve French Date: Mon, 20 Jan 2025 14:41:55 -0600 X-Gm-Features: AbW1kva8I61Vgt-VfIeEluNYwIrwUVNLUr8mF7KIkdhRrMaMPC5FsXloJ9Iu2Ow Message-ID: Subject: Preparing for cifs-utils version 7.2 To: samba-technical , CIFS Cc: Paulo Alcantara , Pavel Shilovsky , Thiago Becker , Henrique Carvalho , Ritvik Budhiraja , Bharath S M , Meetakshi Setiya , =?utf-8?q?Pavel_Filipensk?= =?utf-8?q?=C3=BD?= , Thomas Petazzoni Multiple important patches have been queued up in the cifs-utils for-next branch (see attached or the link https://git.samba.org/?p=cifs-utils.git;a=shortlog;h=refs/heads/for-next and its mirror smb3-utils for-next) over the past four months, and wanted to make sure no objections, or problems to the 14 currently there. Let us know if anything important missing before the next update (to version 7.2) From ecc241229028a5382218aa1402df9efde81353f2 Mon Sep 17 00:00:00 2001 From: Meetakshi Setiya Date: Mon, 11 Nov 2024 00:10:53 -0500 Subject: [PATCH 03/14] use enums to check password or password2 in set_password, get_password_from_file and minor documentation additions Signed-off-by: Meetakshi Setiya Reviewed-by: Bharath SM Signed-off-by: Steve French --- mount.cifs.c | 33 ++++++++++++++++++--------------- mount.cifs.rst | 10 +++++----- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/mount.cifs.c b/mount.cifs.c index 71a2032..041e64f 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -336,8 +336,10 @@ static int mount_usage(FILE * stream) */ static int set_password(struct parsed_mount_info *parsed_info, const char *src, - const int is_pass2) + const int which_pass) { + int is_pass2 = which_pass == OPT_PASS2 || which_pass == CRED_PASS2; + char *dst = is_pass2 ? parsed_info->password2 : parsed_info->password; unsigned int pass_length = is_pass2 ? @@ -638,12 +640,12 @@ static int open_cred_file(char *file_name, parsed_info->got_user = 1; break; case CRED_PASS: - i = set_password(parsed_info, temp_val, 0); + i = set_password(parsed_info, temp_val, CRED_PASS); if (i) goto return_i; break; case CRED_PASS2: - i = set_password(parsed_info, temp_val, 1); + i = set_password(parsed_info, temp_val, CRED_PASS2); if (i) goto return_i; break; @@ -673,9 +675,10 @@ return_i: static int get_password_from_file(int file_descript, char *filename, struct parsed_mount_info *parsed_info, const char *program, - const int is_pass2) + const int which_pass) { int rc = 0; + int is_pass2 = which_pass == OPT_PASS2; unsigned int pass_length = is_pass2 ? sizeof(parsed_info->password2) : sizeof(parsed_info->password); char buf[pass_length + 1]; @@ -720,7 +723,7 @@ get_password_from_file(int file_descript, char *filename, goto get_pw_exit; } - rc = set_password(parsed_info, buf, is_pass2); + rc = set_password(parsed_info, buf, which_pass); get_pw_exit: if (filename != NULL) @@ -928,7 +931,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) parsed_info->got_password = 1; goto nocopy; } - rc = set_password(parsed_info, value, 0); + rc = set_password(parsed_info, value, OPT_PASS); if (rc) return rc; goto nocopy; @@ -943,7 +946,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) parsed_info->got_password2 = 1; goto nocopy; } - rc = set_password(parsed_info, value, 1); + rc = set_password(parsed_info, value, OPT_PASS2); if (rc) return rc; goto nocopy; @@ -1426,25 +1429,25 @@ static int get_pw_from_env(struct parsed_mount_info *parsed_info, const char *pr int rc = 0; if (getenv("PASSWD")) - rc = set_password(parsed_info, getenv("PASSWD"), 0); + rc = set_password(parsed_info, getenv("PASSWD"), OPT_PASS); else if (getenv("PASSWD_FD")) rc = get_password_from_file(atoi(getenv("PASSWD_FD")), NULL, - parsed_info, program, 0); + parsed_info, program, OPT_PASS); else if (getenv("PASSWD_FILE")) rc = get_password_from_file(0, getenv("PASSWD_FILE"), - parsed_info, program, 0); + parsed_info, program, OPT_PASS); if (rc < 0) return rc; if (getenv("PASSWD2")) - rc = set_password(parsed_info, getenv("PASSWD2"), 1); + rc = set_password(parsed_info, getenv("PASSWD2"), OPT_PASS2); else if (getenv("PASSWD2_FD")) rc = get_password_from_file(atoi(getenv("PASSWD2_FD")), NULL, - parsed_info, program, 1); + parsed_info, program, OPT_PASS2); else if (getenv("PASSWD2_FILE")) rc = get_password_from_file(0, getenv("PASSWD2_FILE"), - parsed_info, program, 1); + parsed_info, program, OPT_PASS2); return rc; } @@ -1983,7 +1986,7 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info, } // no need to prompt for password2 - if (!parsed_info->got_password) { + if (!parsed_info->got_password && !(parsed_info->flags & MS_REMOUNT)) { char tmp_pass[MOUNT_PASSWD_SIZE + 1]; char *prompt = NULL; @@ -1991,7 +1994,7 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info, prompt = NULL; if (get_password(prompt ? prompt : "Password: ", tmp_pass, MOUNT_PASSWD_SIZE + 1)) { - rc = set_password(parsed_info, tmp_pass, 0); + rc = set_password(parsed_info, tmp_pass, OPT_PASS); } else { fprintf(stderr, "Error reading password, exiting\n"); rc = EX_SYSERR; diff --git a/mount.cifs.rst b/mount.cifs.rst index d461d0a..5281896 100644 --- a/mount.cifs.rst +++ b/mount.cifs.rst @@ -943,12 +943,12 @@ The variable ``USER`` may contain the username of the person to be used to authenticate to the server. The variable can be used to set both username and password by using the format ``username%password``. -The variable ``PASSWD`` may contain the password of the person using -the client. +The variables ``PASSWD`` and ``PASSWD2`` may contain the password and the +alternate password of the person using the client, respectively. -The variable ``PASSWD_FILE`` may contain the pathname of a file to read -the password from. A single line of input is read and used as the -password. +The variables ``PASSWD_FILE`` and ``PASSWD2_FILE`` may contain the +pathname of the file to read password or password2 from, respectively. +A single line of input is read and used as the password in each case. ***** NOTES -- 2.43.0