CMS 3D CMS Logo

FileAcl.h

Go to the documentation of this file.
00001 #ifndef CLASSLIB_FILE_ACL_H
00002 # define CLASSLIB_FILE_ACL_H
00003 
00004 //<<<<<< INCLUDES                                                       >>>>>>
00005 
00006 # include "classlib/utils/UserInfo.h"
00007 # undef unix // FIXME: visible on too many systems
00008 
00009 namespace lat {
00010 //<<<<<< PUBLIC DEFINES                                                 >>>>>>
00011 //<<<<<< PUBLIC CONSTANTS                                               >>>>>>
00012 //<<<<<< PUBLIC TYPES                                                   >>>>>>
00013 //<<<<<< PUBLIC VARIABLES                                               >>>>>>
00014 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>
00015 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
00016 
00017 // FIXME: Encapsulate UNIX file permssions (ugo/rwx, sticky, suid/sgid)
00018 // and Windows SECURITY_ATTRIBUTES
00019 class FileAcl
00020 {
00021 public:
00022     // FIXME: Owner, group recorded here?
00023 
00024     // Protection bits: (perm & FileAcl::XXXBits) >> FileAcl::XXXOffset
00025     enum {
00026         ReadBit         = 4,
00027         WriteBit        = 2,
00028         ExecBit         = 1,
00029 
00030         OwnerOffset     = 6,
00031         OwnerBits       = 7 << OwnerOffset,
00032         OwnerRead       = ReadBit  << OwnerOffset,
00033         OwnerWrite      = WriteBit << OwnerOffset,
00034         OwnerExec       = ExecBit  << OwnerOffset,
00035 
00036         GroupOffset     = 3,
00037         GroupBits       = 7 << GroupOffset,
00038         GroupRead       = ReadBit  << GroupOffset,
00039         GroupWrite      = WriteBit << GroupOffset,
00040         GroupExec       = ExecBit  << GroupOffset,
00041 
00042         OtherOffset     = 0,
00043         OtherBits       = 7 << OtherOffset,
00044         OtherRead       = ReadBit  << OtherOffset,
00045         OtherWrite      = WriteBit << OtherOffset,
00046         OtherExec       = ExecBit  << OtherOffset,
00047 
00048         ReadBits        = OwnerRead | GroupRead | OtherRead,
00049         WriteBits       = OwnerWrite | GroupWrite | OtherWrite,
00050         ExecBits        = OwnerExec | GroupExec | OtherExec,
00051 
00052         Sticky          = 1 << 10,
00053         SetGID          = 1 << 11,
00054         SetUID          = 1 << 12,
00055 
00056         // Non-standard specialities (Windows, HP-UX, ...)
00057         Hidden          = 1 << 13,       // S_CDF on HP-UX
00058         System          = 1 << 14,
00059         Archive         = 1 << 15,
00060 
00061         Encrypted       = 1 << 16,
00062         NotIndexed      = 1 << 17,
00063         Offline         = 1 << 18,
00064         Temporary       = 1 << 19
00065     };
00066 
00067     FileAcl (void);
00068     FileAcl (int unixPerms, UID uid = UID (-1), GID gid = GID (-1));
00069     // implicit copy constructor
00070     // implicit assignment operator
00071     // implicit destructor
00072 
00073     UID                 owner (void) const;
00074     void                owner (UID uid);
00075     GID                 group (void) const;
00076     void                group (GID gid);
00077 
00078     int                 portable (void) const;
00079     int                 addPortable (int mask);
00080 
00081     int                 unix (void) const;
00082     int                 addUnix (int mask);
00083 
00084     bool                readonly (void) const;
00085 
00086 #ifdef _WIN32
00087     // void             native (SECURITY_ATTRIBUTES *sa, void *buf, DWORD size) const;
00088     // int              addNative (DWORD attributes);
00089 #else
00090     int                 native (void) const;
00091     int                 addNative (int mode);
00092 #endif
00093 
00094 private:
00095     UID                 m_owner;        //< File's owner.
00096     GID                 m_group;        //< File's group (FIXME: Windows?).
00097     int                 m_perms;
00098 };
00099 
00100 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
00101 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
00102 
00103 } // namespace lat
00104 #endif // CLASSLIB_FILE_ACL_H

Generated on Tue Jun 9 17:38:51 2009 for CMSSW by  doxygen 1.5.4