//------------------------------------------------------------------------------ // Copyright (c) 2004, Perforce Software, Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //------------------------------------------------------------------------------ #ifndef ADMINUSER_H # define ADMINUSER_H class StrBufDict; class FileList; class AdminUser : public ClientUser { public: AdminUser(); ~AdminUser(); virtual void OutputStat( StrDict *varList ); StrDict * Modes() { return md; } FileList * WorkList() { return files; } // // Subclasses must implement this method. Used to determine if the // worklist files should be chmod'ed or not. // virtual int ChmodFiles() = 0; // // Subclasses may reimplement this method to determine the mode // to be used for files affected by specific commands. // virtual int GetMode( StrDict *varList, StrBuf &mode ); // // Returns non-zero if the file in question is executable. For some // that means headType contains the +x modifier, for others it's the // 'type' field. This class may be reimplemented in subclasses. The // default implementation looks for xtext or xbinary in the field // returned by GetFileType() // virtual int IsExecutable( StrDict *varList ); // // Returns non-zero if the file should be left in a writable state, // May be reimplemented in subclasses. The default implementation bases // it's decision on the file type returned by GetFileType(). // virtual int IsWritable( StrDict *varList ); // // Return a pointer to the file type from the varList. This allows // subclasses to dictate whether the results of IsExecutable() or // IsWritable() are determined from the 'type' field of an opened file, // or from the headType field (or something else entirely: beware!). The // default implementation uses 'headType'. // virtual StrPtr * GetFileType( StrDict *varList ); enum { BM_EX = 01111, BM_RD = 04444, BM_WR = 02222 }; protected: void SetMode( StrPtr *path, StrPtr *mode); void PushFile( StrPtr *file ); void PopFile(); protected: StrBufDict *md; StrBuf mode; FileList * files; }; #endif
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 4662 | Tony Smith |
Add the first release of my Perforce command line client for Unix sysadmins. On a Unix box, some of the files you really want under version control need to be protected. P4 uses the user's umask to control the permissions on the files it manages but when you're managing a unix box these permissions can vary on a per-file basis and that makes it tricky to manage unix boxes properly with Perforce. Enter P4U. It uses the 2004.2 server's ability to store per-revision attributes to store a permission-mask for each file that requires custom handling. The bits in the mask are removed from the permissions of the relevant files when normal Perforce commands are executed using 'p4u' instead of 'p4'. i.e. p4u add /etc/shadow p4u attribute -n unixMask -v 077 /etc/shadow p4u submit This will cause /etc/shadow to have the mode you would hope for (0400). The mode will be restricted whenever you: p4u submit p4u edit p4u revert p4u sync Currently that's it. |