From patchwork Mon Jun 27 13:58:26 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ville_Skytt=C3=A4?= X-Patchwork-Id: 11925 Received: from smtp3.pp.htv.fi ([213.243.153.36]) by www.linuxtv.org with esmtp (Exim 4.34) id 1Dmu87-0000yh-EP for vdr@linuxtv.org; Mon, 27 Jun 2005 15:58:31 +0200 Received: from cs78131082.pp.htv.fi (cs78131082.pp.htv.fi [62.78.131.82]) by smtp3.pp.htv.fi (Postfix) with ESMTP id 35C6527ACC2 for ; Mon, 27 Jun 2005 16:58:27 +0300 (EEST) Subject: Re: [vdr] [PATCH] time warp From: Ville =?ISO-8859-1?Q?Skytt=E4?= To: Klaus Schmidinger's VDR In-Reply-To: <20050627090014.GA29105@suse.de> References: <42B457E7.9040501@t-online.de> <42B53879.7000507@cadsoft.de> <42BE0822.9050202@gmx.de> <42BE5F2F.2070201@t-online.de> <42BF398C.5040406@gmx.de> <20050627090014.GA29105@suse.de> Date: Mon, 27 Jun 2005 16:58:26 +0300 Message-Id: <1119880706.22291.207.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 (2.2.2-5) X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2005 13:58:31 -0000 Status: O X-Status: X-Keywords: X-UID: 3284 On Mon, 2005-06-27 at 11:00 +0200, Ludwig Nussel wrote: > Udo Richter wrote: > > > > Nice, but I'll have to merge it with the settime patch (using external > > shell script to set time via sudo). Not a big deal, I'll write something > > similar to yours. > > Let vdr do the user switching and save yourself from such hacks: > http://www.suse.de/~lnussel/vdr/vdr-1.3.24-su.diff Nifty. Attached is a patch (to be applied over the above one) that makes it use the reentrant get*nam variants, making it compilable with a "thread poison" patched VDR. Caveat: I don't claim to understand the patch fully, it was mostly kind of borrowed from dbus :) --- vdr.c~ 2005-06-27 12:22:26.000000000 +0300 +++ vdr.c 2005-06-27 12:45:13.000000000 +0300 @@ -100,13 +100,17 @@ { gid_t ngid = 0; struct group* grp = NULL; + struct group grp_str; struct passwd *user = NULL; + struct passwd user_str; + int result; + char buf[1024]; if(!username) return 0; errno = 0; - user = getpwnam(username); - if(!user) + result = getpwnam_r(username, &user_str, buf, sizeof(buf), &user); + if (result != 0 || user != &user_str) { fprintf(stderr,"invalid user %s: %s\n",username,errno?strerror(errno):"user does not exist"); endpwent(); @@ -116,8 +120,8 @@ if(groupname) { errno = 0; - grp = getgrnam(groupname); - if(!grp) + result = getgrnam_r(groupname, &grp_str, buf, sizeof(buf), &grp); + if (result != 0 || grp != &grp_str) { fprintf(stderr,"invalid group %s: %s\n",groupname,errno?strerror(errno):"group does not exist"); endgrent();