some fixes.... Re: connections.tdb & messages.tdb getting full of junk
Toomas Soome
tsoome at ut.ee
Mon Jan 8 22:47:02 GMT 2001
regarding to junk... there is second posting of some of my work. there
are some issues fixed - look into diff's attached.
one problem was wrong usage of pointer, while reading session id from
tdb:
diff -r1.20.4.3 connection.c
341c341
< slotnum = (int) dbuf.dptr; ## this is POINTER, you cant juse
it like that!
---
> slotnum = *((int*)dbuf.dptr); ### this is correct way to do
my letter from december follows:
quota fix for solaris.
problems:
1. debug messages are useing octal devno but they are hex in /etc/mnttab
(at least in sol8) - this is hard to follow...
2. more serious problem - quotas file search is expensive - especially
if server uses lots of nfs mounts and some nfs server is down.... so,
mnt.mnt_fstype == "nfs" should not be tested at all (until rquota call
will be implemented). also, it makes sense only to test fstype ufs and
vxfs. another thing - as devno is saved as mount option in /etc/mnttab,
we do not have to use (expensive) stat() at all - hasmntopt() is just
ok.
3. we should cache variable 'found' with devno_cached. if not - code
will try to find quotas file with last line from /etc/mnttab - and this
is not correct.
utmp related fixes:
1. utmp session fails to be closed in utmp_yield(). problem is actually
in utmp_yield_tdb, connection numbed will be saved into utmp.tdb, but
utmp_yield_tdb will return pointer to this number, not the number
itself.
2. "smb/session_id" in ut_line will confuse finger and other tools (at
least in solaris). the fix is to create dummy /dev/smb/session_id files
- symlinks to /dev/null. current code assumes existing /dev/smb
directory for smb/%d type records, its easy to add call to mkdir() as
well. I left it out because I'm not sure about group for this
directory.... I guess, need for /dev/smb directory should be documented
in smb.conf manpage as well....
context diffs are against SAMBA_2_2 cvs sources.
toomas
--
Life is both difficult and time consuming.
-------------- next part --------------
Index: quotas.c
===================================================================
RCS file: /cvsroot/samba/source/smbd/quotas.c,v
retrieving revision 1.34.4.1
diff -c -r1.34.4.1 quotas.c
*** quotas.c 2000/12/04 20:06:31 1.34.4.1
--- quotas.c 2000/12/22 17:19:03
***************
*** 244,249 ****
--- 244,250 ----
#if defined(SUNOS5)
#include <sys/fs/ufs_quota.h>
#include <sys/mnttab.h>
+ #include <sys/mntent.h>
#else /* defined(SUNOS4) */
#include <ufs/quota.h>
#include <mntent.h>
***************
*** 264,269 ****
--- 265,271 ----
int file;
static struct mnttab mnt;
static pstring name;
+ pstring devopt;
#else /* SunOS4 */
struct mntent *mnt;
static pstring name;
***************
*** 272,278 ****
SMB_STRUCT_STAT sbuf;
SMB_DEV_T devno ;
static SMB_DEV_T devno_cached = 0 ;
! int found ;
euser_id = geteuid();
--- 274,280 ----
SMB_STRUCT_STAT sbuf;
SMB_DEV_T devno ;
static SMB_DEV_T devno_cached = 0 ;
! static int found ;
euser_id = geteuid();
***************
*** 280,286 ****
return(False) ;
devno = sbuf.st_dev ;
! DEBUG(5,("disk_quotas: looking for path \"%s\" devno=%o\n", path,devno));
if ( devno != devno_cached ) {
devno_cached = devno ;
#if defined(SUNOS5)
--- 282,288 ----
return(False) ;
devno = sbuf.st_dev ;
! DEBUG(5,("disk_quotas: looking for path \"%s\" devno=%x\n", path,devno));
if ( devno != devno_cached ) {
devno_cached = devno ;
#if defined(SUNOS5)
***************
*** 288,299 ****
return(False) ;
found = False ;
while (getmntent(fd, &mnt) == 0) {
! if ( sys_stat(mnt.mnt_mountp,&sbuf) == -1 )
! continue ;
! DEBUG(5,("disk_quotas: testing \"%s\" devno=%o\n",
! mnt.mnt_mountp,sbuf.st_dev));
! if (sbuf.st_dev == devno) {
found = True ;
break ;
}
--- 290,306 ----
return(False) ;
found = False ;
+ snprintf(devopt, sizeof(devopt) - 1, "dev=%x", devno);
while (getmntent(fd, &mnt) == 0) {
! if( !hasmntopt(&mnt, devopt) )
! continue;
!
! DEBUG(5,("disk_quotas: testing \"%s\" %s\n", mnt.mnt_mountp,devopt));
!
! /* quotas are only on vxfs, UFS or NFS, but nfs is not supported here */
! if ( strcmp( mnt.mnt_fstype, MNTTYPE_UFS ) == 0 ||
! strcmp( mnt.mnt_fstype, "vxfs" ) == 0 )
! {
found = True ;
break ;
}
***************
*** 322,330 ****
endmntent(fd) ;
#endif
- if ( ! found )
- return(False) ;
}
save_re_uid();
set_effective_uid(0);
--- 329,338 ----
endmntent(fd) ;
#endif
}
+
+ if ( ! found )
+ return(False) ;
save_re_uid();
set_effective_uid(0);
-------------- next part --------------
Index: connection.c
===================================================================
RCS file: /cvsroot/samba/source/smbd/connection.c,v
retrieving revision 1.20.4.3
diff -c -r1.20.4.3 connection.c
*** connection.c 2000/12/14 21:47:54 1.20.4.3
--- connection.c 2000/12/22 17:31:11
***************
*** 338,344 ****
}
/* Save our result */
! slotnum = (int) dbuf.dptr;
/* Tidy up */
tdb_delete(tdb_utmp, kbuf);
--- 338,344 ----
}
/* Save our result */
! slotnum = *((int*)dbuf.dptr);
/* Tidy up */
tdb_delete(tdb_utmp, kbuf);
***************
*** 756,761 ****
--- 756,773 ----
#endif /* HAVE_UPDWTMPX */
}
#endif /* HAVE_UTMPX_H */
+ /*
+ * Test and create /dev/ut_line. this will be symlink to /dev/null.
+ * this is needed for finger and others... TS.
+ */
+ if (claim) {
+ pstring line_tmp;
+ snprintf(line_tmp, sizeof(line_tmp), "/dev/%s", u->ut_line);
+ DEBUG(2,("utmp_update: terminal path: %s\n", line_tmp));
+ unlink(line_tmp);
+ symlink( "/dev/null", line_tmp);
+ utime(line_tmp, NULL); /* touch line to make user "current" */
+ }
}
/*
More information about the samba-technical
mailing list