/****************************************************************************
gets either a hex number (0xNNN) or decimal integer (NNN).
****************************************************************************/
-int get_number(const char *tmp)
+uint32 get_number(const char *tmp)
{
if (strnequal(tmp, "0x", 2))
{
- return strtol(tmp, (char**)NULL, 16);
+ return strtoul(tmp, (char**)NULL, 16);
}
else
{
- return strtol(tmp, (char**)NULL, 10);
+ return strtoul(tmp, (char**)NULL, 10);
}
}
return NULL;
}
- (*n) = get_number(p);
+ (*n) = (int)get_number(p);
if (strnequal(p, "0x", 2))
{
return(S_ISREG(sbuf->st_mode));
}
+/*******************************************************************
+ rename a unix file
+********************************************************************/
+int file_rename(char *from, char *to)
+{
+ int rcode = rename (from, to);
+
+ if (errno == EXDEV)
+ {
+ /* Rename across filesystems needed. */
+ rcode = copy_reg (from, to);
+ }
+ return rcode;
+}
+
/*******************************************************************
check a files mod time
********************************************************************/
}
+/****************************************************************************
+Setup the groups a user belongs to.
+****************************************************************************/
+int get_unixgroups(char *user, uid_t uid, gid_t gid, int *p_ngroups, gid_t **p_groups)
+{
+ int i,ngroups;
+ gid_t grp = 0;
+ gid_t *groups = NULL;
+
+ if (-1 == initgroups(user,gid))
+ {
+ if (getuid() == 0)
+ {
+ DEBUG(0,("Unable to initgroups!\n"));
+ if (gid < 0 || gid > 16000 || uid < 0 || uid > 16000)
+ {
+ DEBUG(0,("This is probably a problem with the account %s\n", user));
+ }
+ }
+ return -1;
+ }
+
+ ngroups = sys_getgroups(0,&grp);
+ if (ngroups <= 0)
+ {
+ ngroups = 32;
+ }
+
+ if((groups = (gid_t *)malloc(sizeof(gid_t)*ngroups)) == NULL)
+ {
+ DEBUG(0,("get_unixgroups malloc fail !\n"));
+ return -1;
+ }
+
+ ngroups = sys_getgroups(ngroups,groups);
+
+ (*p_ngroups) = ngroups;
+ (*p_groups) = groups;
+
+ DEBUG( 3, ( "%s is in %d groups: ", user, ngroups ) );
+ for (i = 0; i < ngroups; i++ )
+ {
+ DEBUG( 3, ( "%s%d", (i ? ", " : ""), (int)groups[i] ) );
+ }
+ DEBUG( 3, ( "\n" ) );
+
+ return 0;
+}
+
/*******************************************************************
turn a uid into a user name
********************************************************************/
int ret;
if(lp_ole_locking_compat()) {
- SMB_OFF_T mask = ((SMB_OFF_T)0xC) << (SMB_OFF_T_BITS-4);
SMB_OFF_T mask2= ((SMB_OFF_T)0x3) << (SMB_OFF_T_BITS-4);
+ SMB_OFF_T mask = (mask2<<2);
/* make sure the count is reasonable, we might kill the lockd otherwise */
count &= ~mask;
if ((offset & mask) != 0)
offset = (offset & ~mask) | (((offset & mask) >> 2) & mask2);
} else {
- SMB_OFF_T mask = ((SMB_OFF_T)0x8) << (SMB_OFF_T_BITS-4);
+ SMB_OFF_T mask2 = ((SMB_OFF_T)0x4) << (SMB_OFF_T_BITS-4);
+ SMB_OFF_T mask = (mask2<<1);
SMB_OFF_T neg_mask = ~mask;
/* interpret negative counts as large numbers */