From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cs.msu.ru; s=dkim; h=Subject:In-Reply-To:Content-Type:MIME-Version:References:Message-ID :Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=xgYYFSnTd7btE+TNHOROPd/tUvNhZj8+gI3iOqTQqZs=; b=O/4seVs/8qUbcGav5zAyG69obZ TZdWj5Mgn4NSWrraffFnPjDuGrhWh75w5ZPgq2Qh5WX6ixmb9F47MGyY/nzbj5jMw+FUjJyEXCBKA 1n0tzsc9bZ/RuSJ5ywoEKFVjCetlykNkqbVMQsDKdpCLhSZK+Fv8GbKG2likD98EuocPro81eidry VBJaut0rcmYH8KQ4UJdk5maUO6ZJXgYlLyC4xA3qa/G4yCsfxCbgYrM8cfbEy8k4R4KWkCJxMTfE3 QCvTzQRZYaKSz/YDtTo4VrK1Ny7/KxFiy4Rh54fyxfHyGpPaHe0dp4SmU/WOxJzzuN6c2CtEovCg7 7mjhOy0A==; Date: Thu, 17 Sep 2020 16:55:15 +0300 From: Arseny Maslennikov To: ALT Linux Team development discussions Message-ID: <20200917135515.GM286846@cello> References: <9bca7626b593f896de4283cba2d6290ec99eb4f2.1576183643.git.legion@altlinux.org> <20200917131127.GF286846@cello> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="KSyhVCl2eeZHT0Rn" Content-Disposition: inline In-Reply-To: <20200917131127.GF286846@cello> OpenPGP: url=http://grep.cs.msu.ru/~ar/pgp-key.asc X-SA-Exim-Connect-IP: 10.7.5.179 X-SA-Exim-Mail-From: ar@cs.msu.ru X-SA-Exim-Version: 4.2.1 X-SA-Exim-Scanned: Yes (on mail.cs.msu.ru) Cc: Alex Gladkov , ldv@altlinux.org Subject: Re: [devel] [PATCH hasher-priv v1 1/3] caller.c X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2020 13:55:20 -0000 Archived-At: List-Archive: List-Post: --KSyhVCl2eeZHT0Rn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline > On Fri, Dec 13, 2019 at 12:42:03PM +0100, Alex Gladkov wrote: > > diff --git a/hasher-priv/caller.c b/hasher-priv/caller.c > > index e83084a..031ddef 100644 > > --- a/hasher-priv/caller.c > > +++ b/hasher-priv/caller.c > > @@ -19,62 +19,67 @@ > > > > #include "priv.h" > > #include "xmalloc.h" > > +#include "logging.h" > > > > -const char *caller_user, *caller_home; > > -uid_t caller_uid; > > -gid_t caller_gid; > > +char *caller_user = NULL; > > +char *caller_home = NULL; > > +uid_t caller_uid; > > +gid_t caller_gid; > > > > /* > > * Initialize caller_user, caller_uid, caller_gid and caller_home. > > */ > > -void > > -init_caller_data(void) > > +int > > +init_caller_data(uid_t uid, gid_t gid) > > { > > - const char *logname; > > struct passwd *pw = 0; > > > > - caller_uid = getuid(); > > - if (caller_uid < MIN_CHANGE_UID) > > - error(EXIT_FAILURE, 0, "caller has invalid uid: %u", > > - caller_uid); > > - > > - caller_gid = getgid(); > > - if (caller_gid < MIN_CHANGE_GID) > > - error(EXIT_FAILURE, 0, "caller has invalid gid: %u", > > - caller_gid); > > - > > - if ((logname = getenv("LOGNAME"))) > > - if (!*logname || strchr(logname, ':')) > > - logname = 0; > > - > > - if (logname) > > - { > > - pw = getpwnam(logname); > > - if (caller_uid != pw->pw_uid || caller_gid != pw->pw_gid) > > - pw = 0; > > + caller_uid = uid; > > + if (caller_uid < MIN_CHANGE_UID) { > > + err("caller has invalid uid: %u", caller_uid); > > + return -1; > > + } > > + > > + caller_gid = gid; > > + if (caller_gid < MIN_CHANGE_GID) { > > + err("caller has invalid gid: %u", caller_gid); > > + return -1; > > } > > > > - if (!pw) > > - pw = getpwuid(caller_uid); > > + pw = getpwuid(caller_uid); > > > > - if (!pw || !pw->pw_name) > > - error(EXIT_FAILURE, 0, "caller lookup failure"); > > + if (!pw || !pw->pw_name) { > > + err("caller lookup failure"); > > + return -1; > > + } > > > > caller_user = xstrdup(pw->pw_name); > > > > - if (caller_uid != pw->pw_uid) > > - error(EXIT_FAILURE, 0, "caller %s: uid mismatch", > > - caller_user); > > + if (caller_uid != pw->pw_uid) { > > + err("caller %s: uid mismatch", caller_user); > > + return -1; > > + } > > > > - if (caller_gid != pw->pw_gid) > > - error(EXIT_FAILURE, 0, "caller %s: gid mismatch", > > - caller_user); > > + if (caller_gid != pw->pw_gid) { > > + err("caller %s: gid mismatch", caller_user); > > + return -1; > > + } > > > > errno = 0; > > if (pw->pw_dir && *pw->pw_dir) > > caller_home = canonicalize_file_name(pw->pw_dir); > > > > - if (!caller_home || !*caller_home) > > - error(EXIT_FAILURE, errno, "caller %s: invalid home", > > - caller_user); > > + if (!caller_home || !*caller_home) { > > + err("caller %s: invalid home: %m", caller_user); > > + return -1; > > + } > > + > > + return 0; > > +} > > + > > +void > > +free_caller_data(void) > > +{ > > + free(caller_user); > > + free(caller_home); > > } Eeeh. Since I did not have any comments about this file, I believe this file is OK. Sorry for the noise. --KSyhVCl2eeZHT0Rn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE56JD3UKTLEu/ddrm9dQjyAYL01AFAl9jar8ACgkQ9dQjyAYL 01AB5RAAo6A6UYEsTZLVV1+tFQrWHwCKvGq3iods3mSpPZf7CBtUBoUMZYAyQp+y fLdeyJlMEIZb/vAv2JRcBUrD4BmSQuLQXxMSyAb2zgqZZG6ruvu5Xg4CIYxQdiYm JHJVnZ4cGC+xSe59AtQ5aJvkhYBcGSCON/Mg2TSjw/MIYdQM12xqllwLCzOb38vs bjfJPzCLXrFrBJP9UgJdAyL1CRjsfoTIsaEC1YHeb6USa4Xl2r+kpoX4Jpw6kmNk 6m4zKCkEDcXCT5rsO2K8BQdxI2HjQ8g4O97XmUI4Co/99QIMCYlTsfMlu053Sg0h eG26OXA2YSFrqcqDaZvHgNRkXx3wgL6U+RT3086PAQbW8EqBlemE7y3K/DWlu0nw FLn+LcBWCXUgofjbb7FH0/ghHn5+izgyEBgvrrxVmnz+N6a3BeZAUryBFDpKe9am NDs21yxwXbp2qBd9kKhn8fFe+mtoqUMbxb9LZ/zYjURFMT9dttBW4tXiJBsSa0lY bJz8OvtOEs+ww+jkDi4gUuNtFTgnXppkbda4kksWUYGaaUp6O3etYuM7LbMWn/bx Rl3BP05qfKoeL3pS+mpw0xGoluFnEX+KKvZ2vSjuTbKAGd5K5JCvyTtZROjxLmMU CihHFJc4n7XilwWFPmf/uiVD8JvTA/6w2X7gSLCowJbRvBTpRvk= =fwgQ -----END PGP SIGNATURE----- --KSyhVCl2eeZHT0Rn--