From owner-freebsd-hackers Sat Sep 14 19:57:54 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DC49437B400 for ; Sat, 14 Sep 2002 19:57:50 -0700 (PDT) Received: from milla.ask33.net (milla.ask33.net [217.197.166.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id 203FE43E42 for ; Sat, 14 Sep 2002 19:57:50 -0700 (PDT) (envelope-from nick@milla.ask33.net) Received: by milla.ask33.net (Postfix, from userid 1001) id 23A6C3ABD40; Sun, 15 Sep 2002 05:01:57 +0200 (CEST) Date: Sun, 15 Sep 2002 05:01:57 +0200 From: Pawel Jakub Dawidek To: freebsd-hackers@freebsd.org Subject: Changing process informations. Message-ID: <20020915030157.GP68652@garage.freebsd.pl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="eQyCKlb8USywWNtC" Content-Disposition: inline X-PGP-Key-URL: http://garage.freebsd.pl/jules.pgp X-OS: FreeBSD 4.6-STABLE i386 User-Agent: Mutt/1.5.1i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --eQyCKlb8USywWNtC Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello hackers... When I want change process real or effective uid in kld module I got functions change_ruid() and change_euid(). I need change many others informations about process. Correct me if I'm wrong: void change_svuid(struct proc *p, uid_t svuid) { struct pcred *pc =3D p->p_cred; if (pc->p_svuid !=3D svuid) { pc->p_svuid =3D svuid; setsugid(p); } } void change_rgid(struct proc *p, gid_t rgid) { struct pcred *pc =3D p->p_cred; if (pc->p_rgid !=3D rgid) { pc->p_rgid =3D rgid; setsugid(p); } } void change_egid(struct proc *p, gid_t egid) { struct pcred *pc =3D p->p_cred; if (pc->pc_ucred->cr_groups[0] !=3D egid) { pc->pc_ucred =3D crcopy(pc->pc_ucred); pc->pc_ucred->cr_groups[0] =3D egid; setsugid(p); } } void change_rgid(struct proc *p, gid_t svgid) { struct pcred *pc =3D p->p_cred; if (pc->p_svgid !=3D svgid) { pc->p_svgid =3D svgid; setsugid(p); } } void addgroup(struct proc *p, gid_t gid) { struct pcred *pc =3D p->p_cred; if (groupmember(gid, pc->pc_ucred)) return; if (pc->pc_ucred->cr_ngroups >=3D NGROUPS) return; pc->pc_ucred =3D crcopy(pc->pc_ucred); /* XXX: Have to be here? */ pc->pc_ucred->cr_groups[pc->pc_ucred->cr_ngroups] =3D gid; pc->pc_ucred->cr_ngroups++; setsugid(p); /* XXX: Have to be here? */ } void delgroup(struct proc *p, gid_t gid) { struct pcred *pc =3D p->p_cred; u_int i; if (!groupmember(gid, pc->pc_ucred)) return; for (i =3D 0; pc->pc_ucred->cr_groups[i] !=3D gid; ++i) ; pc->pc_ucred =3D crcopy(pc->pc_ucred); /* XXX: Have to be here? */ for (; i < pc->pc_ucred->cr_ngroups; ++i) { /* Yes, some copy operation could be a bit faster, but... */ pc->pc_ucred->cr_groups[i] =3D pc->pc_ucred->cr_groups[i + 1]; } pc->pc_ucred->cr_ngroups--; setsugid(p); /* XXX: Have to be here? */ } That's all for now. --=20 Pawel Jakub Dawidek UNIX Systems Administrator http://garage.freebsd.pl Am I Evil? Yes, I Am. --=20 Pawel Jakub Dawidek UNIX Systems Administrator http://garage.freebsd.pl Am I Evil? Yes, I Am. --eQyCKlb8USywWNtC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iQCVAwUBPYP4JT/PhmMH/Mf1AQFqBAP+ICPhoqadqgDeGbqp6iOrdY1hQaiquCvp NmK5tkX74wgsXHzy1ch1LNH8k1zAku8zh3+JyRGDxPygujZxkuzrEXSOgq0AEQjl ZMdw2lmvd0Jpm7kml3FXFdYW+fMzLd8hCB4WfpJQThaQ11rQ04OXQI+RMxM1ZptN G0jVdyH15GE= =/ZQR -----END PGP SIGNATURE----- --eQyCKlb8USywWNtC-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message