summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/include/proto.h2
-rw-r--r--source/lib/charcnv.c2
-rw-r--r--source/libsmb/namequery.c117
-rw-r--r--source/smbd/dfree.c11
-rw-r--r--source/smbd/noquotas.c10
-rw-r--r--source/smbd/quotas.c43
-rw-r--r--source/utils/smbpasswd.c18
7 files changed, 124 insertions, 79 deletions
diff --git a/source/include/proto.h b/source/include/proto.h
index 472052c807c..9a4a95e9eda 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -2196,7 +2196,7 @@ int reply_negprot(connection_struct *conn,
/*The following definitions come from smbd/noquotas.c */
-BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
+BOOL disk_quotas(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize);
/*The following definitions come from smbd/nttrans.c */
diff --git a/source/lib/charcnv.c b/source/lib/charcnv.c
index b016a07fd73..29ef72d7ac3 100644
--- a/source/lib/charcnv.c
+++ b/source/lib/charcnv.c
@@ -225,6 +225,6 @@ void interpret_character_set(char *str)
} else if (strequal (str, "koi8-r")) {
init_koi8_r();
} else {
- DEBUG(0,("unrecognized character set\n"));
+ DEBUG(0,("unrecognized character set %s\n", str));
}
}
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c
index e95302fcd0c..0e92e6b5dd8 100644
--- a/source/libsmb/namequery.c
+++ b/source/libsmb/namequery.c
@@ -247,60 +247,81 @@ struct in_addr *name_query(int fd,char *name,int name_type, BOOL bcast,BOOL recu
retries--;
while (1)
+ {
+ struct timeval tval2;
+ GetTimeOfDay(&tval2);
+ if (TvalDiff(&tval,&tval2) > retry_time)
{
- struct timeval tval2;
- GetTimeOfDay(&tval2);
- if (TvalDiff(&tval,&tval2) > retry_time) {
- if (!retries) break;
- if (!found && !send_packet(&p))
- return NULL;
- GetTimeOfDay(&tval);
- retries--;
- }
+ if (!retries)
+ break;
+ if (!found && !send_packet(&p))
+ return NULL;
+ GetTimeOfDay(&tval);
+ retries--;
+ }
- if ((p2=receive_packet(fd,NMB_PACKET,90)))
- {
- struct nmb_packet *nmb2 = &p2->packet.nmb;
- debug_nmb_packet(p2);
+ if ((p2=receive_packet(fd,NMB_PACKET,90)))
+ {
+ struct nmb_packet *nmb2 = &p2->packet.nmb;
+ debug_nmb_packet(p2);
- if (nmb->header.name_trn_id != nmb2->header.name_trn_id ||
- !nmb2->header.response) {
- /* its not for us - maybe deal with it later
- (put it on the queue?) */
- if (fn)
- fn(p2);
- else
- free_packet(p2);
- continue;
- }
+ if (nmb->header.name_trn_id != nmb2->header.name_trn_id ||
+ !nmb2->header.response)
+ {
+ /*
+ * Its not for us - maybe deal with it later
+ * (put it on the queue?).
+ */
+ if (fn)
+ fn(p2);
+ else
+ free_packet(p2);
+ continue;
+ }
- if (nmb2->header.opcode != 0 ||
- nmb2->header.nm_flags.bcast ||
- nmb2->header.rcode ||
- !nmb2->header.ancount) {
- /* XXXX what do we do with this? could be a redirect, but
- we'll discard it for the moment */
- free_packet(p2);
- continue;
- }
+ if (nmb2->header.opcode != 0 ||
+ nmb2->header.nm_flags.bcast ||
+ nmb2->header.rcode ||
+ !nmb2->header.ancount)
+ {
+ /*
+ * XXXX what do we do with this? Could be a redirect, but
+ * we'll discard it for the moment.
+ */
+ free_packet(p2);
+ continue;
+ }
- ip_list = (struct in_addr *)Realloc(ip_list, sizeof(ip_list[0]) *
- ((*count)+nmb2->answers->rdlength/6));
- if (ip_list) {
- DEBUG(fn?3:2,("Got a positive name query response from %s ( ",
- inet_ntoa(p2->ip)));
- for (i=0;i<nmb2->answers->rdlength/6;i++) {
- putip((char *)&ip_list[(*count)],&nmb2->answers->rdata[2+i*6]);
- DEBUG(fn?3:2,("%s ",inet_ntoa(ip_list[(*count)])));
- (*count)++;
- }
- DEBUG(fn?3:2,(")\n"));
- }
- found=True; retries=0;
- free_packet(p2);
- if (fn) break;
- }
+ ip_list = (struct in_addr *)Realloc(ip_list, sizeof(ip_list[0]) *
+ ((*count)+nmb2->answers->rdlength/6));
+ if (ip_list)
+ {
+ DEBUG(fn?3:2,("Got a positive name query response from %s ( ",
+ inet_ntoa(p2->ip)));
+ for (i=0;i<nmb2->answers->rdlength/6;i++)
+ {
+ putip((char *)&ip_list[(*count)],&nmb2->answers->rdata[2+i*6]);
+ DEBUG(fn?3:2,("%s ",inet_ntoa(ip_list[(*count)])));
+ (*count)++;
+ }
+ DEBUG(fn?3:2,(")\n"));
+ }
+
+ found=True;
+ retries=0;
+ free_packet(p2);
+ if (fn)
+ break;
+
+ /*
+ * If we're doing a unicast lookup we only
+ * expect one reply. Don't wait the full 2
+ * seconds if we got one. JRA.
+ */
+ if(!bcast && found)
+ break;
}
+ }
return ip_list;
}
diff --git a/source/smbd/dfree.c b/source/smbd/dfree.c
index c96a599e77b..020386645c2 100644
--- a/source/smbd/dfree.c
+++ b/source/smbd/dfree.c
@@ -188,13 +188,24 @@ static int fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
static SMB_BIG_UINT disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize)
{
int dfree_retval;
+ SMB_BIG_UINT dfree_q = 0;
+ SMB_BIG_UINT bsize_q = 0;
+ SMB_BIG_UINT dsize_q = 0;
(*dfree) = (*dsize) = 0;
(*bsize) = 512;
fsusage(path, dfree, dsize);
+ if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) {
+ (*bsize) = bsize_q;
+ (*dfree) = MIN(*dfree,dfree_q);
+ (*dsize) = MIN(*dsize,dsize_q);
+ }
+
+ /* FIXME : Any reason for this assumption ? */
if (*bsize < 256) {
+ DEBUG(5,("disk_free:Warning: bsize == %d < 256 . Changing to assumed correct bsize = 512\n",*bsize));
*bsize = 512;
}
diff --git a/source/smbd/noquotas.c b/source/smbd/noquotas.c
index c62fb368c74..5c55bb47c8e 100644
--- a/source/smbd/noquotas.c
+++ b/source/smbd/noquotas.c
@@ -25,7 +25,15 @@
* Needed for auto generation of proto.h.
*/
-BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
+BOOL disk_quotas(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize)
{
+ (*bsize) = 512; /* This value should be ignored */
+
+ /* And just to be sure we set some values that hopefully */
+ /* will be larger that any possible real-world value */
+ (*dfree) = (SMB_BIG_UINT)-1;
+ (*dsize) = (SMB_BIG_UINT)-1;
+
+ /* As we have select not to use quotas, allways fail */
return False;
}
diff --git a/source/smbd/quotas.c b/source/smbd/quotas.c
index d610bbe15a4..d5ecf73451b 100644
--- a/source/smbd/quotas.c
+++ b/source/smbd/quotas.c
@@ -45,7 +45,7 @@ _syscall4(int, quotactl, int, cmd, const char *, special, int, id, caddr_t, addr
try to get the disk space from disk quotas (LINUX version)
****************************************************************************/
-BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
+BOOL disk_quotas(char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
uid_t euser_id;
int r;
@@ -130,7 +130,8 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
/****************************************************************************
try to get the disk space from disk quotas (CRAY VERSION)
****************************************************************************/
-BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
+
+BOOL disk_quotas(char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
struct mntent *mnt;
FILE *fd;
@@ -227,6 +228,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
#elif defined(SUNOS5) || defined(SUNOS4)
#include <fcntl.h>
+#include <sys/param.h>
#if defined(SUNOS5)
#include <sys/fs/ufs_quota.h>
#include <sys/mnttab.h>
@@ -236,10 +238,11 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
#endif
/****************************************************************************
-try to get the disk space from disk quotas (solaris 2 version)
-****************************************************************************/
+try to get the disk space from disk quotas (SunOS & Solaris2 version)
/* Quota code by Peter Urbanec (amiga@cse.unsw.edu.au) */
-BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
+****************************************************************************/
+
+BOOL disk_quotas(char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
uid_t user_id, euser_id;
int ret;
@@ -249,7 +252,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
int file;
struct mnttab mnt;
static pstring name;
-#else
+#else /* SunOS4 */
struct mntent *mnt;
static pstring name;
#endif
@@ -285,7 +288,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
pstrcpy(name,mnt.mnt_mountp) ;
pstrcat(name,"/quotas") ;
fclose(fd) ;
-#else
+#else /* SunOS4 */
if ((fd = setmntent(MOUNTED, "r")) == NULL)
return(False) ;
@@ -336,7 +339,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
seteuid(euser_id);
if (ret < 0) {
- DEBUG(2,("disk_quotas ioctl (Solaris) failed\n"));
+ DEBUG(5,("disk_quotas ioctl (Solaris) failed. Error = %s\n", strerror(errno) ));
return(False);
}
@@ -349,17 +352,18 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
if (D.dqb_bsoftlimit==0)
return(False);
- *bsize = 512;
+ *bsize = DEV_BSIZE;
*dfree = D.dqb_bsoftlimit - D.dqb_curblocks;
*dsize = D.dqb_bsoftlimit;
+
if(*dfree < 0)
{
*dfree = 0;
*dsize = D.dqb_curblocks;
}
-DEBUG(5,("disk_quotas for path \"%s\" returning bsize %d, dfree %d, dsize %d\n",
- path,*bsize,*dfree,*dsize));
+ DEBUG(5,("disk_quotas for path \"%s\" returning bsize %.0f, dfree %.0f, dsize %.0f\n",
+ path,(double)*bsize,(double)*dfree,(double)*dsize));
return(True);
}
@@ -371,7 +375,8 @@ DEBUG(5,("disk_quotas for path \"%s\" returning bsize %d, dfree %d, dsize %d\n"
/****************************************************************************
try to get the disk space from disk quotas - OFS1 version
****************************************************************************/
-BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
+
+BOOL disk_quotas(char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
uid_t user_id, euser_id;
int r, save_errno;
@@ -426,7 +431,7 @@ try to get the disk space from disk quotas (IRIX 6.2 version)
#include <sys/quota.h>
#include <mntent.h>
-BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
+BOOL disk_quotas(char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
uid_t euser_id;
int r;
@@ -518,11 +523,8 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
(F.d_ino_hardlimit && F.d_icount>=F.d_ino_hardlimit)
)
{
- /*
- * Fixme!: these are __uint64_t, this may truncate values
- */
*dfree = 0;
- *dsize = (int) F.d_bcount;
+ *dsize = F.d_bcount;
}
else if (F.d_blk_softlimit==0 && F.d_blk_hardlimit==0)
{
@@ -530,8 +532,8 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
}
else
{
- *dfree = (int)(F.d_blk_softlimit - F.d_bcount);
- *dsize = (int)F.d_blk_softlimit;
+ *dfree = (F.d_blk_softlimit - F.d_bcount);
+ *dsize = F.d_blk_softlimit;
}
}
@@ -565,7 +567,8 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
/****************************************************************************
try to get the disk space from disk quotas - default version
****************************************************************************/
-BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
+
+BOOL disk_quotas(char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
uid_t euser_id;
int r;
diff --git a/source/utils/smbpasswd.c b/source/utils/smbpasswd.c
index 2d4ce319e84..147e3492af2 100644
--- a/source/utils/smbpasswd.c
+++ b/source/utils/smbpasswd.c
@@ -191,7 +191,8 @@ int main(int argc, char **argv)
extern char *optarg;
extern int optind;
extern int DEBUGLEVEL;
- int real_uid;
+ uid_t real_uid;
+ uid_t eff_uid;
struct passwd *pwd = NULL;
fstring old_passwd;
fstring new_passwd;
@@ -217,7 +218,7 @@ int main(int argc, char **argv)
char *new_domain = NULL;
pstring servicesf = CONFIGFILE;
void *vp;
- struct nmb_name calling, called;
+ struct nmb_name calling, called;
new_passwd[0] = '\0';
@@ -265,16 +266,17 @@ int main(int argc, char **argv)
codepage_initialise(lp_client_code_page());
- /* Get the real uid */
+ /* Get the real and effective uids */
real_uid = getuid();
-
+ eff_uid = geteuid();
+
/* Check the effective uid */
- if ((geteuid() == 0) && (real_uid != 0)) {
+ if ((eff_uid == (uid_t)0) && (real_uid != (uid_t)0)) {
fprintf(stderr, "%s: Must *NOT* be setuid root.\n", prog_name);
exit(1);
}
- is_root = (real_uid == 0);
+ is_root = (eff_uid == (uid_t)0);
while ((ch = getopt(argc, argv, "adehmnj:r:sR:D:U:")) != EOF) {
switch(ch) {
@@ -434,7 +436,7 @@ int main(int argc, char **argv)
exit(1);
}
} else {
- if((pwd = getpwuid(real_uid)) != NULL)
+ if((pwd = getpwuid(eff_uid)) != NULL)
pstrcpy( user_name, pwd->pw_name);
}
@@ -463,7 +465,7 @@ int main(int argc, char **argv)
got_new_pass = True;
}
- if(!remote_user_name && ((pwd = getpwuid(real_uid)) != NULL))
+ if(!remote_user_name && ((pwd = getpwuid(eff_uid)) != NULL))
pstrcpy( user_name, pwd->pw_name);
/*