home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / isowner.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-25  |  1.3 KB  |  56 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: isowner.c,v 1.7 1998/10/25 00:52:43 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    isowner.c
  7.  * Author:    T.E.Dickey
  8.  * Created:    20 Dec 1984
  9.  * Last update:
  10.  *        24 Oct 1998, limit getuid/getgid compares to 16-bits
  11.  *        25 Oct 1995, missing parenthesis
  12.  *        19 Feb 1995, str/sys utils prototypes
  13.  *        04 Nov 1988, removed masking from getuid/getgid calls.
  14.  *        12 Nov 1985, patch (for v4.x) to use only low-byte of uid codes
  15.  *        20 Dec 1984
  16.  *
  17.  * Function:    Test (for FLIST) a file's UIC to see if it is either owned
  18.  *        by the current process, or if the process has sufficient
  19.  *        privilege to modify it.
  20.  *
  21.  * Arguments:    z    => FILENT structure defining file.
  22.  */
  23.  
  24. #include    <stdio.h>
  25. #include    <string.h>
  26. #include    <unixlib.h>    /* for 'getuid()' */
  27.  
  28. #include    <prvdef.h>
  29.  
  30. #include    "flist.h"
  31. #include    "dirent.h"
  32.  
  33. #include    "strutils.h"
  34. #include    "sysutils.h"
  35.  
  36. #define    CMP(func,offset) ((func() & 0xffff) != z->offset)
  37.  
  38. int    isowner (FILENT *z)
  39. {
  40.     char    msg    [CRT_COLS];
  41.  
  42.     if ((CMP(getgid,f_grp) || CMP(getuid,f_mbm))
  43.     && ! sysrights(PRV$M_SYSPRV,0))
  44.     {
  45.         strcpy (msg, "You are not the file's owner");
  46.         if (z->f_grp == -1)
  47.             strcat (msg, "(NO Privilege)");
  48.         else
  49.             sprintf (strnull(msg), ": [%03o,%03o]",
  50.                 z->f_grp, z->f_mbm);
  51.         warn2 (msg);
  52.         return (FALSE);
  53.     }
  54.     return (TRUE);
  55. }
  56.