Samba VFS Module and Crashes

William234 at aol.com William234 at aol.com
Thu Jun 27 11:49:02 GMT 2002


Hello,

I have downloaded and compiled Samba 2.2.5 and have begun to play with the 
VFS features.  While this version of VFS seems vastly improved over 2.2.2 
(the last time i looked at VFS) I am still running into some problems and I 
cannot for the life of me figure out how to debug them

I took the audit.c VFS module and modified it to output the information to a 
Postgres database.  This seems to work quite well for connecting to services, 
opening existing directories and files.  However, when I try to create a new 
directory (either with explorer or a command prompt), or create a new file, 
Samba panics.  It seems to be panicking somewhere in glibc's implementation 
of mkdir.

Original audit.c 

int audit_mkdir(struct connection_struct *conn, const char *path, mode_t mode)
 {

       
       int result = default_vfs_ops.mkdir(conn, path, mode);
       
       syslog(SYSLOG_PRIORITY, "mkdir %s %s%s\n",
             path,

             (result < 0) ? "failed: " : "",

             (result < 0) ? strerror(errno) : "");



       return result;


}

My psqlaudit.c

int audit_mkdir(struct connection_struct *conn, const char *path, mode_t mode)
 {


       int result;

       time_t curtime;

       PGresult *res;

       char sqlstmt[256];

       char tme[9];

       char date[11];

       
       result = default_vfs_ops.mkdir(conn, path, mode);

       if(result == 0) {


             sqlstmt[0] = '\0';


             curtime = time(NULL);

             strftime(date, sizeof(date), "%F", localtime(&curtime));

             strftime(tme, sizeof(date), "%T", localtime(&curtime));


             safe_strcat(sqlstmt, "INSERT INTO audit VALUES ('", 255);

             safe_strcat(sqlstmt, conn->user, 255);

             safe_strcat(sqlstmt, "', '", 255);

             safe_strcat(sqlstmt, tme, 255);

             safe_strcat(sqlstmt, "', '", 255);

             safe_strcat(sqlstmt, date, 255);

             safe_strcat(sqlstmt, "', '", 255);

             safe_strcat(sqlstmt, "Make Directory", 255);

             safe_strcat(sqlstmt, "', '", 255);

             safe_strcat(sqlstmt, path, 255);

             safe_strcat(sqlstmt, "', '", 255);

             safe_strcat(sqlstmt, conn->client_address, 255);

             safe_strcat(sqlstmt, "')\0", 255);


             res = PQexec(dbconn, sqlstmt);

             PQclear(res);

       
       }

       return result;


}

Somehow moving from the original audit.c to my new code causes the crash.  
Now, when smbd restarts, the directory has been created and is available.

Is there something better to use then safe_strcat()?  Possibly 
safe_sprintf()?

Bill Miller
William234 at aol.com
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the samba-technical mailing list