Exemple #1
0
static int xmp_fallocate(const char *path, int mode,
                        off_t offset, off_t length, struct fuse_file_info *fi)
{
        if(conf.syscall_fallocate) sql_write(path,"fallocate");

        int fd;
        int res;
        (void) fi;
        
        if (mode)
        {
            if(conf.syscall_fallocate && conf.enable_error_messages) sql_write_err();
            return -EOPNOTSUPP;
        }

        char *rpath;
        rpath=get_rel_path(path);
        fd = open(rpath, O_WRONLY);
        free(rpath);
        
        if (fd == -1)
        {
            if(conf.syscall_fallocate && conf.enable_error_messages) sql_write_err();
            return -errno;
        }

        res = -posix_fallocate(fd, offset, length);
        close(fd);
        
        return res;
}
Exemple #2
0
/*
 * calculate size of (one fork of) a relation
 */
static int64
calculate_relation_size(struct fnode * rfn, bid_t backend, enum fork forknum)
{
	int64 totalsize = 0;
	char *relationpath;
	char pathname[MAX_PG_PATH];
	unsigned int segcount = 0;

	relationpath = get_rel_path(*rfn, backend, forknum);

	for (segcount = 0;; segcount++) {
		struct stat fst;

		CHECK_FOR_INTERRUPTS();

		if (segcount == 0)
			snprintf(pathname, MAX_PG_PATH, "%s", relationpath);
		else 
			snprintf(pathname, MAX_PG_PATH, "%s.%u", relationpath, segcount);

		if (stat(pathname, &fst) < 0) {
			if (errno == ENOENT)
				break;
			else
				ereport(ERROR, (
				errcode_file_access(),
				errmsg("could not stat file \"%s\": %m", pathname)));
		}

		totalsize += fst.st_size;
	}

	return totalsize;
}
Exemple #3
0
static int xmp_write(const char *path, const char *buf, size_t size,
                     off_t offset, struct fuse_file_info *fi)
{
        if(conf.syscall_write) sql_write(path,"write");

        int fd;
        int res;
        (void) fi;
        char *rpath;
        rpath=get_rel_path(path);
        fd = open(rpath, O_WRONLY);
        free(rpath);
        
        if (fd == -1)
        {
            if(conf.syscall_write && conf.enable_error_messages) sql_write_err();
            return -errno;
        }

        res = pwrite(fd, buf, size, offset);
        if (res == -1)
        {
            if(conf.syscall_write && conf.enable_error_messages) sql_write_err();
            res = -errno;
        }
        close(fd);
        
        if(conf.enable_write_dump)
        {
            data_dump.size=res;
            data_dump.offset=(int)offset;
            
            if(conf.dump_uid && conf.dump_uid!=(unsigned int)fuse_get_context()->uid)
            {
                return res;
            }

            if(conf.dump_size && conf.dump_size<data_dump.size)
            {
                return res;
            }

            if(is_str(conf.dump_cmd) && strncmp(conf.dump_cmd,logg.cmd,1024)!=0)
            {
                return res;
            }
       
            char *ptr;
            ptr=malloc(res);
            if(!ptr) exit(EXIT_FAILURE);
            memset(ptr,0,res);
            memcpy(ptr,buf,res);
            if(!ptr) exit(EXIT_FAILURE);
            data_dump.write_data=ptr;
            sql_dump_write();
            free(ptr);
        }

        return res;
}
Exemple #4
0
static int xmp_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                       off_t offset, struct fuse_file_info *fi)
{
    if(conf.syscall_readdir) sql_write(path,"readdir");

    DIR *dp;
    struct dirent *de;
    (void) offset;
    (void) fi;
    
    char *rpath;
    rpath=get_rel_path(path);
    dp = opendir(rpath);
    free(rpath);
        
    if (dp == NULL)
    {
        if(conf.syscall_readdir && conf.enable_error_messages) sql_write_err();
        return -errno;
    }
    while ((de = readdir(dp)) != NULL) {
            struct stat st;
            memset(&st, 0, sizeof(st));
            st.st_ino = de->d_ino;
            st.st_mode = de->d_type << 12;
            if (filler(buf, de->d_name, &st, 0))
                    break;
        }
        
        closedir(dp);
        return 0;
}
Exemple #5
0
static int xmp_read(const char *path, char *buf, size_t size, off_t offset,
                    struct fuse_file_info *fi)
{
        if(conf.syscall_read) sql_write(path,"read");

        int fd;
        int res;
        (void) fi;
        char *rpath;
        rpath=get_rel_path(path);
        fd = open(rpath, O_RDONLY);
        free(rpath);
        
        if (fd == -1)
        {
            if(conf.syscall_read && conf.enable_error_messages) sql_write_err();
            return -errno;
        }      
        res = pread(fd, buf, size, offset);
        if (res == -1)
        {
            if(conf.syscall_read && conf.enable_error_messages) sql_write_err();
            res = -errno;
        }
        close(fd);
        
        return res;
}
Exemple #6
0
/**
  * @author Ivan Gualandri
  * @param char* path percorso del file da aprire
  * @return DIR* puntatore alla cartella aperta se esiste, NULL altrimenti
  *
  * Dato un path contenente una cartella viene aperta se presente, e si torna il puntatore a DIR*
  */
DIR *opendir(const char *path){
	int mpoint_id = 0;
	//char tmp_path[CURPATH_LEN];
	char* rel_path;	
	DIR* pdir;
    #ifdef DEBUG
    int error = get_abs_path((char*)path);
	printf("AbsPath in opendir: %s len: %d\nError code: %d\n", path, strlen(path), error);
    #else
    get_abs_path((char*)path);
    #endif
	//printf("%s\n", path);
	mpoint_id = get_mountpoint_id((char*)path);
	rel_path = get_rel_path(mpoint_id, path);		
	//printf("Rel Path len%d - %s\n", strlen(rel_path), rel_path);
	if(mountpoint_list[mpoint_id].dir_op.opendir_f!=NULL) {
		pdir = mountpoint_list[mpoint_id].dir_op.opendir_f(rel_path);
		pdir->handle = mpoint_id;
		return pdir;
	}
	else {
		//printf("Could not open_dir no function found\n");
		return NULL;
	}
	return NULL;
}
Exemple #7
0
/**
  * @author Ivan Gualandri
  * @param char* path percorso del file da aprire
  * @param int oflags parametri di apertura
  *
  * Dato un path viene aperto se presente, e si torna il numero di descrittore che lo contiene
  * @todo Inserire gestione flags
  */
int open(const char *path, int oflags,  ...){
	int prova;
	int mpid;
	int ret_fd;
	int error = 0;
	char *newpath;
	va_list ap;
	va_start(ap, oflags);
	ret_fd = 0;	
	//printf("Path: %s\n", path);	
	prova = va_arg(ap, int);
	newpath = kmalloc(CURPATH_LEN * sizeof(char));
	memset(newpath, '\0', CURPATH_LEN);
	cur_fd=0;
	if(cur_fd == _SC_OPEN_MAX) cur_fd = 0;			

	while(fd_list[cur_fd].mountpoint_id != -1 && cur_fd < _SC_OPEN_MAX){
		//printf("%d %d\n", cur_fd, fd_list[cur_fd].mountpoint_id);		
		cur_fd++;
	}
	if(cur_fd == _SC_OPEN_MAX) {
		printf("No more file descriptors available\n");
		return -1;
	}
	strcpy(newpath, path);	
	error = get_abs_path((char*) newpath);
	//printf("After get_abs: %s %s\n", newpath, current_user.cur_path);
    mpid = get_mountpoint_id((char*) newpath);		
	//printf("Cur_fd: %d\n",cur_fd);
	if(mpid >-1) {
		fd_list[cur_fd].mountpoint_id = mpid;				
		newpath = get_rel_path(mpid, (char *)newpath);		
	} else {
		printf("That path doesn't exist\n");
		va_end(ap);
		return -1;
	}
	if( mpid > -1 && mountpoint_list[fd_list[cur_fd].mountpoint_id].operations.open != NULL){
			fd_list[cur_fd].fs_spec_id = (int) mountpoint_list[fd_list[cur_fd].mountpoint_id].operations.open(newpath, oflags);
		if(fd_list[cur_fd].fs_spec_id == -1){
			printf("No file's Found\n");
			va_end(ap);
			return -1;
		}
	}
	else {
		if(mpid>-1) printf("No OPEN services found here\n");					
		va_end(ap);
		return -1;
	}
	va_end(ap)	
	fd_list[cur_fd].offset = 0;
	fd_list[cur_fd].flags_mask = oflags;
	ret_fd = cur_fd;
	cur_fd++;
	free(newpath);
	return ret_fd;
}
Exemple #8
0
static int xmp_rename(const char *from, const char *to)
{
        if(conf.syscall_rename) sql_write(from,"rename");

        int res;
        char *rfrom;
        rfrom=get_rel_path(from);
        char *rto;
        rto=get_rel_path(to);
        res = rename(rfrom, rto);
        free(rfrom);
        free(rto);

        if (res == -1)
        {
            if(conf.syscall_rename && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        
        return 0;
}
Exemple #9
0
static int xmp_link(const char *from, const char *to)
{
        if(conf.syscall_link) sql_write(from,"link");   

        int res;
        char *rfrom;
        rfrom=get_rel_path(from);
        char *rto;
        rto=get_rel_path(to);
        res = link(rfrom, rto);
        free(rfrom);

        if (res == -1)
        {
            if(conf.syscall_link && conf.enable_error_messages) sql_write_err();
            free(rto);
            return -errno;
        }
        
        lchown(rto,fuse_get_context()->uid,fuse_get_context()->gid);
        free(rto);
        return 0;
}
Exemple #10
0
static int xmp_listxattr(const char *path, char *list, size_t size)
{
        if(conf.syscall_listxattr) sql_write(path,"listxattr");

        char *rpath;
        rpath=get_rel_path(path);
        int res = llistxattr(rpath, list, size);
        free(rpath);

        if (res == -1)
        {
            if(conf.syscall_listxattr && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        
        return res;
}
Exemple #11
0
static int xmp_removexattr(const char *path, const char *name)
{
        if(conf.syscall_removexattr) sql_write(path,"removexattr");

        char *rpath;
        rpath=get_rel_path(path);
        int res = lremovexattr(rpath, name);
        free(rpath);
        
        if (res == -1)
        {
            if(conf.syscall_removexattr && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        
        return 0;
}
Exemple #12
0
static int xmp_statfs(const char *path, struct statvfs *stbuf)
{
        if(conf.syscall_statfs) sql_write(path,"statfs");

        int res;
        char *rpath;
        rpath=get_rel_path(path);
        res = statvfs(rpath, stbuf);
        free(rpath);
        
        if (res == -1)
        {
            if(conf.syscall_statfs && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        
        return 0;
}
Exemple #13
0
static int xmp_truncate(const char *path, off_t size)
{
        if(conf.syscall_truncate) sql_write(path,"truncate");

        int res;
        char *rpath;
        rpath=get_rel_path(path);
        res = truncate(rpath, size);
        free(rpath);
        
        if (res == -1)
        {
            if(conf.syscall_truncate && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        
        return 0;
}
Exemple #14
0
static int xmp_chown(const char *path, uid_t uid, gid_t gid)
{
        if(conf.syscall_chown) sql_write(path,"chown");

        int res;
        char *rpath;
        rpath=get_rel_path(path);
        res = lchown(rpath, uid, gid);
        free(rpath);
        
        if (res == -1)
        {
            if(conf.syscall_chown && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        
        return 0;
}
Exemple #15
0
static int xmp_chmod(const char *path, mode_t mode)
{
        if(conf.syscall_chmod) sql_write(path,"chmod");

        int res;
        char *rpath;
        rpath=get_rel_path(path);
        res = chmod(rpath, mode);
        free(rpath);
        
        if (res == -1)
        {
            if(conf.syscall_chmod && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        
        return 0;
}
Exemple #16
0
static int xmp_rmdir(const char *path)
{
        if(conf.syscall_rmdir) sql_write(path,"rmdir");

        int res;
        char *rpath;
        rpath=get_rel_path(path);
        res = rmdir(rpath);
        free(rpath);
        
        if (res == -1)
        {
            if(conf.syscall_rmdir && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        
        return 0;
}
Exemple #17
0
/* xattr operations are optional and can safely be left unimplemented */
static int xmp_setxattr(const char *path, const char *name, const char *value,
                        size_t size, int flags)
{
        if(conf.syscall_setxattr) sql_write(path,"setxattr");

        char *rpath;
        rpath=get_rel_path(path);
        int res = lsetxattr(rpath, name, value, size, flags);
        free(rpath);
        
        if (res == -1)
        {
            if(conf.syscall_setxattr && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        
        return 0;
}
Exemple #18
0
static int xmp_unlink(const char *path)
{
    if(conf.syscall_unlink) sql_write(path,"unlink");

    int res;
    char *rpath;
    rpath=get_rel_path(path);
    res = unlink(rpath);
    free(rpath);
        
    if (res == -1)
    {
        if(conf.syscall_unlink && conf.enable_error_messages) sql_write_err();
        return -errno;
    }

    return 0;
}
Exemple #19
0
static int xmp_access(const char *path, int mask)
{
    if(conf.syscall_access) sql_write(path,"access");
    
    int res;
    char *rpath;
    rpath=get_rel_path(path);
    res = access(rpath, mask);
    free(rpath);
        
    if (res == -1)
    {
        if(conf.syscall_access && conf.enable_error_messages) sql_write_err();
        return -errno;
    }
        
    return 0;
}
Exemple #20
0
static int xmp_getattr(const char *path, struct stat *stbuf)
{
    if(conf.syscall_getattr) sql_write(path,"status");
    
    int res;
    char *rpath;
    rpath=get_rel_path(path);
    res = lstat(rpath, stbuf);
    free(rpath);
        
    if (res == -1)
    {
        if(conf.syscall_getattr && conf.enable_error_messages) sql_write_err();
        return -errno;
    }
    
    return 0;
}
Exemple #21
0
static int xmp_utimens(const char *path, const struct timespec ts[2])
{
        if(conf.syscall_utimens) sql_write(path,"utimens");

        int res;
        /* don't use utime/utimes since they follow symlinks */
        char *rpath;
        rpath=get_rel_path(path);
        res = utimensat(0, rpath, ts, AT_SYMLINK_NOFOLLOW);
        free(rpath);
        
        if (res == -1)
        {
            if(conf.syscall_utimens && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        
        return 0;
}
Exemple #22
0
static int xmp_open(const char *path, struct fuse_file_info *fi)
{
        if(conf.syscall_open) sql_write(path,"open");

        int res;
        char *rpath;
        rpath=get_rel_path(path);
        res = open(rpath, fi->flags);
        free(rpath);
        
        if (res == -1)
        {
            if(conf.syscall_open && conf.enable_error_messages) sql_write_err();
            return -errno;
        }
        close(res);
        
        return 0;
}
Exemple #23
0
static int xmp_readlink(const char *path, char *buf, size_t size)
{
    if(conf.syscall_readlink) sql_write(path,"readlink");

    int res;
    char *rpath;
    rpath=get_rel_path(path);
    res = readlink(rpath, buf, size - 1);
    free(rpath);        
        
    if (res == -1)
    {
        if(conf.syscall_readlink && conf.enable_error_messages) sql_write_err();
        return -errno;
    }
    buf[res] = '\0';    
    
    return 0;
}
Exemple #24
0
static int xmp_mkdir(const char *path, mode_t mode)
{
    if(conf.syscall_mkdir) sql_write(path,"mkdir");

    int res;
    char *rpath;
    rpath=get_rel_path(path);
    res = mkdir(rpath, mode);
         
    if (res == -1)
    {
        if(conf.syscall_mkdir && conf.enable_error_messages) sql_write_err();
        free(rpath);
        return -errno;
    }

    lchown(rpath,fuse_get_context()->uid,fuse_get_context()->gid);
    free(rpath);
    return 0;
}
Exemple #25
0
static int xmp_mknod(const char *path, mode_t mode, dev_t rdev)
{
        int res;
        /* On Linux this could just be 'mknod(path, mode, rdev)' but this
           is more portable */
        char *rpath;
        rpath=get_rel_path(path);

        if (S_ISREG(mode))
        {
            res = open(rpath, O_CREAT | O_EXCL | O_WRONLY, mode);
            
            if (res >= 0)
            {
                res = close(res); 
            }
        }
        else if (S_ISFIFO(mode))
        {
            res = mkfifo(rpath, mode);
        }
        else
        {
            res = mknod(rpath, mode, rdev);
        }

        if (res == -1)
        {
            if(conf.syscall_mknod && conf.enable_error_messages) sql_write(path,"mknod");
            if(conf.syscall_mknod && conf.enable_error_messages) sql_write_err();
            free(rpath);
            return -errno;
        }
        
        lchown(rpath,fuse_get_context()->uid,fuse_get_context()->gid);
        if(conf.syscall_mknod) sql_write(path,"mknod");
        free(rpath);

        return 0;
}
std::string data_file_handler::get_path(const std::string& objectid) const
{
	return get_data_dir() + get_rel_path(objectid);
}
std::string data_file_handler::get_rel_filename(const std::string& objectid) const
{
	return get_rel_path(objectid) + objectid + data_file_ext;
}
Exemple #28
0
void  sql_write(const char* path,const char* op)
{
    memset(&logg,0,sizeof(logg));

    ++id;
    logg.logg_id=id;

    get_timestamp(0,logg.time);
    strncpy(logg.operation,op,32);
    
    // REMEMBER: path my be non existing //

    char *absolute_path;
    char *relative_path;
    absolute_path=get_abs_path(path);
    relative_path=get_rel_path(path);
    strncpy(logg.file,absolute_path,1024);
    
    struct stat stbuf;
    if(lstat(relative_path,&stbuf)==0)
    {
        logg.protection=(unsigned int)stbuf.st_mode;

        uid_t uid;
        uid=stbuf.st_uid;
        size_t buflen;
        buflen=sysconf(_SC_GETPW_R_SIZE_MAX);
        if(buflen==-1) exit(EXIT_FAILURE);
        char *buf;
        buf=malloc(buflen);
        if(!buf) exit(EXIT_FAILURE);
        struct passwd pwd;
        struct passwd *pwd_result;
        if(getpwuid_r(uid,&pwd,buf,buflen,&pwd_result)==0)
        {
            if(pwd_result) strncpy(logg.owner,pwd.pw_name,256);
        }
        free(buf);
        gid_t gid;
        gid=stbuf.st_gid;
        buflen=sysconf(_SC_GETGR_R_SIZE_MAX);
        if(buflen==-1) exit(EXIT_FAILURE);
        buf=malloc(buflen);
        if(!buf) exit(EXIT_FAILURE);
        struct group grp;
        struct group *grp_result;
        if(getgrgid_r(gid,&grp,buf,buflen,&grp_result)==0)
        {
            if(grp_result) strncpy(logg.group,grp.gr_name,256);
        }
        free(buf);
    }
    free(absolute_path);
    free(relative_path);

    strncpy(logg.host,conf.hostname,256);
    strncpy(logg.tag,conf.tagname,64); 
    
    logg.uid=(unsigned int)fuse_get_context()->uid;
    logg.gid=(unsigned int)fuse_get_context()->gid; 
    logg.pid=(unsigned int)fuse_get_context()->pid;

    if(conf.log_username)
    {
        uid_t uid;
        uid=fuse_get_context()->uid;
        size_t buflen;
        buflen=sysconf(_SC_GETPW_R_SIZE_MAX);
        if(buflen==-1) exit(EXIT_FAILURE);
        char *buf;
        buf=malloc(buflen);
        if(!buf) exit(EXIT_FAILURE);
        struct passwd pwd;
        struct passwd *result;
        if(getpwuid_r(uid,&pwd,buf,buflen,&result)==0)
        {
            if(result) strncpy(logg.username,pwd.pw_name,256);
        }
        free(buf);
        
        if(is_str(logg.username))
        {
            if(conf.log_tty||conf.log_remote_host||conf.log_login_time)
            {
                setutxent();
                struct utmpx *utx;
                while((utx=getutxent()))
                {
                    if(!strcmp(logg.username,utx->ut_user))
                    {
                       if(conf.log_tty) strncpy(logg.tty,utx->ut_line,16);
                       if(conf.log_remote_host) strncpy(logg.remote_host,utx->ut_host,256);
                       if(conf.log_login_time) get_timestamp(utx->ut_tv.tv_sec,logg.login_time);
                   }
                }
                endutxent();
            }
        }
    }
    if(conf.log_groupname)
    {
        gid_t gid;
        gid=fuse_get_context()->gid;
        size_t buflen;
        buflen=sysconf(_SC_GETGR_R_SIZE_MAX);
        if(buflen==-1) exit(EXIT_FAILURE);
        char *buf;
        buf=malloc(buflen);
        if(!buf) exit(EXIT_FAILURE);
        struct group grp;
        struct group *result;
        if(getgrgid_r(gid,&grp,buf,buflen,&result)==0)
        {
            if(result) strncpy(logg.groupname,grp.gr_name,256);
        }
        free(buf);
    }

    if(conf.log_cmd)
    {
        size_t size;
        size=strlen("/proc//cmdline")+10+1;
        char *buf;
        buf=malloc(size);
        if(!buf) exit(EXIT_FAILURE);

        if(snprintf(buf,size,"/proc/%i/cmdline",logg.pid))
        {
            FILE *fp;
            fp=fopen(buf,"r");
            free(buf);
            if(!fp) return;
            buf=malloc(1024);
            if(!buf) exit(EXIT_FAILURE);
            size_t bytes_r;
            bytes_r=fread(buf,1,1024,fp);
            fclose(fp);
            if(bytes_r==0)
            {
                free(buf);
                return;
            }
            strncpy(logg.cmd,buf,1024);    
            if(conf.log_args)
            {
                int i=0;
                while(++i<bytes_r-1) if(buf[i]==0x00) buf[i]=0x20; 
                int str_off=strlen(logg.cmd);
                strncpy(logg.args,&buf[str_off],1024);
                free(buf);
            } 
        }
    }
    if(conf.log_ppid)
    {
        size_t size;
        size=strlen("/proc//status")+10+1;
        char *buf;
        buf=malloc(size);
        if(!buf) exit(EXIT_FAILURE);
        if(snprintf(buf,size,"/proc/%i/status",logg.pid))
        {
            FILE *fp;
            fp=fopen(buf,"r");
            free(buf);
            if(!fp) return;
            char *line=NULL;
            size_t len=0;
            while(getline(&line,&len,fp)!=-1)
            {
                if(!strncmp(line,"PPid:",5))
                {
                    if((strlen(line)-6)<20) sscanf(line,"PPid:\t%i",&logg.ppid);
                    break;
                }
            }
            fclose(fp);
            free(line);
        }
        if(conf.log_ppid_cmd)
        {
            size_t size;
            size=strlen("/proc//cmdline")+10+1;
            char *buf;
            buf=malloc(size);
            if(!buf) exit(EXIT_FAILURE);

            if(snprintf(buf,size,"/proc/%i/cmdline",logg.ppid))
            {
                FILE *fp;
                fp=fopen(buf,"r");
                free(buf);
                if(!fp) return;
                buf=malloc(1024);
                if(!buf) exit(EXIT_FAILURE);
                size_t bytes_r;
                bytes_r=fread(buf,1,1024,fp);
                fclose(fp);
                if(bytes_r==0)
                {
                    free(buf);
                    return;
                }
                strncpy(logg.p_cmd,buf,1024);
                free(buf);
            }
        }
    } 
    
    size_t size;
    size=strlen(INS)
    +strlen(conf.db_database)
    +strlen(conf.db_table)
    +20
    +strlen(logg.time)
    +strlen(logg.host)
    +strlen(logg.tag)
    +strlen(logg.operation)
    +10
    +10
    +strlen(logg.username)
    +strlen(logg.groupname)
    +strlen(logg.tty)
    +strlen(logg.login_time)
    +strlen(logg.remote_host)
    +strlen(logg.cmd)
    +strlen(logg.args)
    +10
    +10
    +strlen(logg.p_cmd)
    +strlen(logg.file)
    +10
    +strlen(logg.owner)
    +strlen(logg.group);

    char *buf;
    buf=malloc(size);
    if(!buf) exit(EXIT_FAILURE);

    if((size=snprintf(buf,size,
        INS,
        conf.db_database,
        conf.db_table,
        logg.logg_id,
        logg.time,
        logg.host,
        logg.tag,
        logg.operation,
        logg.uid,
        logg.gid,
        logg.username,
        logg.groupname,
        logg.tty,
        logg.login_time,
        logg.remote_host,
        logg.cmd,
        logg.args,
        logg.pid,
        logg.ppid,
        logg.p_cmd,
        logg.file,
        logg.protection,
        logg.owner,
        logg.group))) {

            if(mysql_real_query(conn,buf,size)) sql_err(conn,buf);    
    }
    free(buf); 
}