/usr/include/root/rpdpriv.h is in libroot-net-auth-dev 5.34.19+dfsg-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | // @(#)root/rpdutils:$Id$
// Author: Gerardo Ganis, March 2011
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_rpdpriv
#define ROOT_rpdpriv
//////////////////////////////////////////////////////////////////////////
// //
// rpdpriv //
// //
// Implementation of a privileges handling API following the paper //
// "Setuid Demystified" by H.Chen, D.Wagner, D.Dean //
// also quoted in "Secure programming Cookbook" by J.Viega & M.Messier. //
// //
// NB: this not thread-safe: it is meant to be used in single-threaded //
// applications //
// //
//////////////////////////////////////////////////////////////////////////
#if !defined(WINDOWS)
# include <sys/types.h>
#else
# define uid_t unsigned int
# define gid_t unsigned int
#endif
class rpdpriv
{
friend class rpdprivguard;
private:
rpdpriv();
static bool debug;
static int changeto(uid_t uid, gid_t gid);
static void dumpugid(const char *msg = 0);
static int restore(bool saved = 1);
public:
virtual ~rpdpriv() { }
static int changeperm(uid_t uid, gid_t gid);
};
//
// Guard class;
// Usage:
//
// { rpdprivguard priv(tempuid);
//
// // Work as tempuid (maybe superuser)
// ...
//
// }
//
class rpdprivguard
{
public:
rpdprivguard(uid_t uid, gid_t gid);
rpdprivguard(const char *user);
virtual ~rpdprivguard();
bool isvalid() const { return valid; }
private:
bool dum;
bool valid;
void init(uid_t uid, gid_t gid);
};
#ifndef rpdbadpguard
#define rpdbadpguard(g,u) (!(g.isvalid()) && (geteuid() != (uid_t)u))
#endif
#endif
|