/* Do the permissions allow some operation? Assumes statcache already set. */
#ifndef VMS /* VMS' cando is in vms.c */
-I32
-Perl_cando(pTHX_ I32 bit, Uid_t effective, register struct stat *statbufp)
-/* Note: we use `effective' both for uids and gids. */
+bool
+Perl_cando(pTHX_ Mode_t mode, Uid_t effective, register Stat_t *statbufp)
+/* Note: we use `effective' both for uids and gids.
+ * Here we are betting on Uid_t being equal or wider than Gid_t. */
{
#ifdef DOSISH
/* [Comments and code from Len Reed]
/* Atari stat() does pretty much the same thing. we set x_bit_set_in_stat
* too so it will actually look into the files for magic numbers
*/
- return (bit & statbufp->st_mode) ? TRUE : FALSE;
+ return (mode & statbufp->st_mode) ? TRUE : FALSE;
#else /* ! DOSISH */
if ((effective ? PL_euid : PL_uid) == 0) { /* root is special */
- if (bit == S_IXUSR) {
+ if (mode == S_IXUSR) {
if (statbufp->st_mode & 0111 || S_ISDIR(statbufp->st_mode))
return TRUE;
}
return FALSE;
}
if (statbufp->st_uid == (effective ? PL_euid : PL_uid) ) {
- if (statbufp->st_mode & bit)
+ if (statbufp->st_mode & mode)
return TRUE; /* ok as "user" */
}
else if (ingroup(statbufp->st_gid,effective)) {
- if (statbufp->st_mode & bit >> 3)
+ if (statbufp->st_mode & mode >> 3)
return TRUE; /* ok as "group" */
}
- else if (statbufp->st_mode & bit >> 6)
+ else if (statbufp->st_mode & mode >> 6)
return TRUE; /* ok as "other" */
return FALSE;
#endif /* ! DOSISH */
p |int |block_start |int full
p |void |boot_core_UNIVERSAL
p |void |call_list |I32 oldscope|AV* av_list
-p |I32 |cando |I32 bit|Uid_t effective|Stat_t* statbufp
+p |bool |cando |Mode_t mode|Uid_t effective|Stat_t* statbufp
p |U32 |cast_ulong |NV f
p |I32 |cast_i32 |NV f
p |IV |cast_iv |NV f
#if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)
s |OP* |doform |CV *cv|GV *gv|OP *retop
-s |int |emulate_eaccess|const char* path|int mode
+s |int |emulate_eaccess|const char* path|Mode_t mode
# if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
s |int |dooneliner |char *cmd|char *filename
# endif
}
#undef Perl_cando
-I32
-Perl_cando(pTHXo_ I32 bit, Uid_t effective, Stat_t* statbufp)
+bool
+Perl_cando(pTHXo_ Mode_t mode, Uid_t effective, Stat_t* statbufp)
{
- return ((CPerlObj*)pPerl)->Perl_cando(bit, effective, statbufp);
+ return ((CPerlObj*)pPerl)->Perl_cando(mode, effective, statbufp);
}
#undef Perl_cast_ulong
|| defined(HAS_SETREGID) || defined(HAS_SETRESGID))
/* The Hard Way. */
STATIC int
-S_emulate_eaccess(pTHX_ const char* path, int mode)
+S_emulate_eaccess(pTHX_ const char* path, Mode_t mode)
{
Uid_t ruid = getuid();
Uid_t euid = geteuid();
#if !defined(PERL_EFF_ACCESS_R_OK)
STATIC int
-S_emulate_eaccess(pTHX_ const char* path, int mode)
+S_emulate_eaccess(pTHX_ const char* path, Mode_t mode)
{
Perl_croak(aTHX_ "switching effective uid is not implemented");
/*NOTREACHED*/
VIRTUAL int Perl_block_start(pTHX_ int full);
VIRTUAL void Perl_boot_core_UNIVERSAL(pTHX);
VIRTUAL void Perl_call_list(pTHX_ I32 oldscope, AV* av_list);
-VIRTUAL I32 Perl_cando(pTHX_ I32 bit, Uid_t effective, Stat_t* statbufp);
+VIRTUAL bool Perl_cando(pTHX_ Mode_t mode, Uid_t effective, Stat_t* statbufp);
VIRTUAL U32 Perl_cast_ulong(pTHX_ NV f);
VIRTUAL I32 Perl_cast_i32(pTHX_ NV f);
VIRTUAL IV Perl_cast_iv(pTHX_ NV f);
#endif
#if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)
STATIC OP* S_doform(pTHX_ CV *cv, GV *gv, OP *retop);
-STATIC int S_emulate_eaccess(pTHX_ const char* path, int mode);
+STATIC int S_emulate_eaccess(pTHX_ const char* path, Mode_t mode);
# if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
STATIC int S_dooneliner(pTHX_ char *cmd, char *filename);
# endif