Enlightenment CVS committal Author : chaos Project : e17 Module : apps/evfs
Dir : e17/apps/evfs/src/plugins/file Modified Files: evfs_fs_posix.c evfs_fs_samba.c evfs_fs_sftp.c evfs_fs_tar.c evfs_fs_vfolder.c Log Message: * Handle auth requests/responses =================================================================== RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_posix.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- evfs_fs_posix.c 25 Jul 2007 17:00:54 -0000 1.9 +++ evfs_fs_posix.c 13 Aug 2007 03:05:21 -0000 1.10 @@ -57,7 +57,7 @@ int evfs_file_write(evfs_filereference * file, char *bytes, long size); int evfs_file_create(evfs_filereference * file); int evfs_file_mkdir(evfs_filereference * file); -void evfs_dir_list(evfs_client * client, evfs_filereference* ref, +void evfs_dir_list(evfs_client * client, evfs_command* command, Ecore_List ** directory_list); /*Internal functions */ @@ -507,7 +507,7 @@ } void -evfs_dir_list(evfs_client * client, evfs_filereference* file, +evfs_dir_list(evfs_client * client, evfs_command* command, Ecore_List ** directory_list) { struct dirent *de; @@ -515,6 +515,8 @@ DIR *dir; Ecore_List *files = ecore_list_new(); char full_name[PATH_MAX]; + + evfs_filereference* file = command->file_command.files[0]; dir = opendir(file->path); while ((de = readdir(dir))) =================================================================== RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_samba.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- evfs_fs_samba.c 11 Aug 2007 10:39:03 -0000 1.14 +++ evfs_fs_samba.c 13 Aug 2007 03:05:22 -0000 1.15 @@ -49,10 +49,12 @@ static SMBCCTX *smb_context = NULL; Ecore_List *auth_cache; +Ecore_List* auth_command_list; + int smb_next_fd; Ecore_Hash *smb_fd_hash; -static void smb_evfs_dir_list(evfs_client * client, evfs_filereference* command, +static void smb_evfs_dir_list(evfs_client * client, evfs_command* command, Ecore_List ** directory_list); int smb_evfs_file_stat(evfs_command * command, struct stat *file_stat, int); int evfs_file_open(evfs_client * client, evfs_filereference * file); @@ -65,6 +67,8 @@ int smb_evfs_file_rename(evfs_client* client, evfs_command* command); int smb_evfs_file_mkdir(evfs_filereference * file); int evfs_file_remove(char *file); +void +evfs_auth_push(evfs_command* command); int evfs_client_disconnect(evfs_client * client) @@ -73,6 +77,53 @@ client->id);*/ } +typedef struct { + evfs_command* command; + evfs_client* client; +} smb_auth_struct; + +smb_auth_struct* evfs_smb_auth_top_get() +{ + smb_auth_struct* as = NULL; + + if (ecore_list_count(auth_command_list) >0) { + ecore_list_first_goto(auth_command_list); + as = ecore_list_current(auth_command_list); + printf("Request for top auth item (count %d): com: %p, cli: %p\n",ecore_list_count(auth_command_list), as->command, as->client); + return ecore_list_current(auth_command_list); + } + + return NULL; +} + +void evfs_smb_auth_push(evfs_command* command, evfs_client* client) +{ + smb_auth_struct* as = NEW(smb_auth_struct); + as->command = command; + as->client = client; + ecore_list_prepend(auth_command_list, as); + + printf("Pushed comm: %p, cli: %p to stack\n", command, client); +} + +void evfs_smb_auth_pop(evfs_command* command) +{ + smb_auth_struct* it; + ecore_list_first_goto(auth_command_list); + + while ( (it=ecore_list_next(auth_command_list))) { + if (it->command = command) { + printf("Popped comm: %p, cli: %p from stack\n", it->command, it->client); + + ecore_list_first_remove(auth_command_list); + free(it); + return; + } + } + + printf("EVFS_SMB: error: Could not find command in auth list\n"); +} + void evfs_auth_structure_add(Ecore_List * cache, char *username, char *password, char *path) @@ -159,9 +210,19 @@ } else { /*Otherwise - fail - ask user -try again - TODO */ + /*strcpy(username, "anonymous"); + strcpy(password, "anonymous");*/ - strcpy(username, "anonymous"); - strcpy(password, "anonymous"); + /*Don't auth for ADMIN shares*/ + if (!strstr(share, "$")) { + printf("Sending auth request to client...\n"); + smb_auth_struct* as = evfs_smb_auth_top_get(); + if (as) { + evfs_auth_failure_event_create(as->client,as->command); + } else { + printf("No command to request auth for in stack.\n"); + } + } } } @@ -191,12 +252,16 @@ functions->evfs_file_mkdir = &smb_evfs_file_mkdir; functions->evfs_file_remove = &evfs_file_remove; + functions->evfs_auth_push = &evfs_auth_push; + printf("Samba stat func at '%p'\n", &smb_evfs_file_stat); auth_cache = ecore_list_new(); smb_fd_hash = ecore_hash_new(ecore_direct_hash, ecore_direct_compare); smb_next_fd = 0; + auth_command_list = ecore_list_new(); + smb_context = smbc_new_context(); if (smb_context != NULL) { @@ -220,17 +285,28 @@ return "smb"; } +void +evfs_auth_push(evfs_command* command) +{ + evfs_auth_structure_add(auth_cache, command->file_command.files[0]->username, + command->file_command.files[0]->password, + command->file_command.files[0]->path); +} + int smb_evfs_file_rename(evfs_client* client, evfs_command* command) { int err; + evfs_smb_auth_push(command, client); + /*TODO: Check that these files are on same filesystem. * This should really be a per-plugin function called from the top level*/ err = smb_context->rename(smb_context, command->file_command.files[0]->path, smb_context, command->file_command.files[1]->path); + evfs_smb_auth_pop(command); return err; } @@ -289,18 +365,21 @@ } static void -smb_evfs_dir_list(evfs_client * client, evfs_filereference * file, +smb_evfs_dir_list(evfs_client * client, evfs_command * command, /*Returns.. */ Ecore_List ** directory_list) { char dir_path[PATH_MAX]; - int size; SMBCFILE *dir = NULL; struct smbc_dirent *entry = NULL; + evfs_filereference* file = command->file_command.files[0]; + Ecore_List *files = ecore_list_new(); + evfs_smb_auth_push(command,client); + /*Does this command have an attached authentication object? */ if (file->username) { @@ -346,16 +425,26 @@ else if (entry->smbc_type == SMBC_LINK) reference->file_type = EVFS_FILE_LINK; - size = - (sizeof(char) * - strlen(file->path)) + - (sizeof(char) * strlen(entry->name)) + (sizeof(char) * 2); - reference->path = malloc(size); - - snprintf(reference->path, size, "%s/%s", - file->path, entry->name); + /*If the entry is a server, rewrite to remove the workgroup, + * if any*/ + if (entry->smbc_type != SMBC_SERVER) { + size = + (sizeof(char) * + strlen(file->path)) + + (sizeof(char) * strlen(entry->name)) + (sizeof(char) * 2); + reference->path = malloc(size); + + snprintf(reference->path, size, "%s/%s", + file->path, entry->name); + } else { + size = (sizeof(char) + (sizeof(char) * strlen(entry->name)) + (sizeof(char) * 2)); + reference->path = malloc(size); + + snprintf(reference->path, size, "/%s", + entry->name); + } - /*printf("File '%s' is of type '%d'\n", reference->path, reference->file_type); */ + /*printf("File '%s' is of type '%d'\n", reference->path, reference->file_type);*/ reference->plugin_uri = strdup("smb"); ecore_list_append(files, reference); @@ -374,6 +463,7 @@ strerror(errno)); } + evfs_smb_auth_pop(command); } int =================================================================== RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_sftp.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- evfs_fs_sftp.c 25 Jul 2007 17:00:54 -0000 1.9 +++ evfs_fs_sftp.c 13 Aug 2007 03:05:22 -0000 1.10 @@ -794,7 +794,7 @@ /*----------------------------------------------------------------*/ void -evfs_dir_list(evfs_client * client, evfs_filereference* ref, Ecore_List ** directory_list); +evfs_dir_list(evfs_client * client, evfs_command* command, Ecore_List ** directory_list); int evfs_file_open(evfs_client * client, evfs_filereference * file); int evfs_file_close(evfs_filereference * file); int evfs_file_seek(evfs_filereference * file, long offset, int whence); @@ -1089,7 +1089,7 @@ } void -evfs_dir_list(evfs_client * client, evfs_filereference* iref, +evfs_dir_list(evfs_client * client, evfs_command* command, /*Returns.. */ Ecore_List ** directory_list) { @@ -1101,6 +1101,8 @@ char* host, *schar; SftpConnection* conn = NULL; + + evfs_filereference* iref = command->file_command.files[0]; sftp_split_host_path(iref->path, &host,&schar); =================================================================== RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_tar.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- evfs_fs_tar.c 29 Jul 2007 10:10:37 -0000 1.10 +++ evfs_fs_tar.c 13 Aug 2007 03:05:22 -0000 1.11 @@ -90,7 +90,7 @@ int evfs_file_read(evfs_filereference * file, char *bytes, long size); int evfs_file_write(evfs_filereference * file, char *bytes, long size); int evfs_file_create(evfs_filereference * file); -void evfs_dir_list(evfs_client * client, evfs_filereference * file, +void evfs_dir_list(evfs_client * client, evfs_command * command, Ecore_List ** directory_list); struct tar_file @@ -420,7 +420,7 @@ } void -evfs_dir_list(evfs_client * client, evfs_filereference *ref, +evfs_dir_list(evfs_client * client, evfs_command* command, /*Returns..*/ Ecore_List ** directory_list) { @@ -430,6 +430,8 @@ Ecore_List *keys; Ecore_List *files = ecore_list_new(); char *key; + + evfs_filereference* ref = command->file_command.files[0]; printf("Listing tar file dir: '%s'\n", ref->path); =================================================================== RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_vfolder.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- evfs_fs_vfolder.c 25 Jul 2007 17:00:54 -0000 1.18 +++ evfs_fs_vfolder.c 13 Aug 2007 03:05:22 -0000 1.19 @@ -44,7 +44,7 @@ //#define EVFS_PLUGIN_VFOLDER_QUERIES_ID "/Queries" #define MAX_GROUP_LENGTH 255 -void evfs_dir_list(evfs_client * client, evfs_filereference* ref, +void evfs_dir_list(evfs_client * client, evfs_command* command, Ecore_List ** directory_list); int @@ -71,13 +71,14 @@ void -evfs_dir_list(evfs_client * client, evfs_filereference* file, +evfs_dir_list(evfs_client * client, evfs_command* command, Ecore_List ** directory_list) { Ecore_List *files = ecore_list_new(); evfs_filereference* ref; char* path; + evfs_filereference* file = command->file_command.files[0]; path = file->path; /*We should make this generic - perhaps a plugin system*/ ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs