Enlightenment CVS committal Author : xcomputerman Project : e17 Module : apps/entrance
Dir : e17/apps/entrance/src/daemon Modified Files: auth.c entranced_display.c ipc.c md5.c spawner.c util.c Log Message: Indent. =================================================================== RCS file: /cvs/e/e17/apps/entrance/src/daemon/auth.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- auth.c 7 Nov 2005 18:41:11 -0000 1.19 +++ auth.c 26 Oct 2006 08:05:55 -0000 1.20 @@ -18,15 +18,15 @@ #define AUTH_DATA_LEN 16 int -entranced_cookie_new (char *cookie) +entranced_cookie_new(char *cookie) { - int fd; - int r; - unsigned char buf[BUFSIZE]; - unsigned char digest[MD5_HASHBYTES]; - double ctime; - pid_t pid; - Entranced_MD5_Context *ctx = NULL; + int fd; + int r; + unsigned char buf[BUFSIZE]; + unsigned char digest[MD5_HASHBYTES]; + double ctime; + pid_t pid; + Entranced_MD5_Context *ctx = NULL; entranced_md5_init(&ctx); @@ -36,17 +36,19 @@ entranced_md5_update(ctx, (unsigned char *) &pid, sizeof(pid)); pid = getppid(); entranced_md5_update(ctx, (unsigned char *) &pid, sizeof(pid)); - - if ((fd = open("/dev/random", O_RDONLY|O_NONBLOCK)) < 0) + + if ((fd = open("/dev/random", O_RDONLY | O_NONBLOCK)) < 0) { - entranced_debug("Cookie generation failed: could not open /dev/random\n"); + entranced_debug + ("Cookie generation failed: could not open /dev/random\n"); return 0; } - if((r = read(fd, buf, sizeof(buf))) <= 0) + if ((r = read(fd, buf, sizeof(buf))) <= 0) { - entranced_debug("Cookie generation failed: could not read /dev/random\n"); + entranced_debug + ("Cookie generation failed: could not read /dev/random\n"); return 0; } @@ -59,33 +61,34 @@ } static void -_entranced_auth_purge(Entranced_Display *d, FILE *auth_file) +_entranced_auth_purge(Entranced_Display * d, FILE * auth_file) { - Xauth *auth; - Ecore_List_Node *li; - Ecore_List *auth_keep = NULL; - + Xauth *auth; + Ecore_List_Node *li; + Ecore_List *auth_keep = NULL; + if (!d || !auth_file) return; entranced_debug("entranced_auth_purge: %s\n", d->name); - fseek (auth_file, 0L, SEEK_SET); - + fseek(auth_file, 0L, SEEK_SET); + auth_keep = ecore_list_new(); ecore_list_set_free_cb(auth_keep, ECORE_FREE_CB(XauDisposeAuth)); - /* Read each auth entry and check if it matches one for this - * display */ + /* Read each auth entry and check if it matches one for this display */ while ((auth = XauReadAuth(auth_file))) { int match; + match = 0; for (li = d->auths->first; li; li = li->next) { Xauth *disp_auth = (Xauth *) li->data; - if (!memcmp(disp_auth->address, auth->address, auth->address_length) && - !memcmp(disp_auth->number, auth->number, auth->number_length)) + + if (!memcmp(disp_auth->address, auth->address, auth->address_length) + && !memcmp(disp_auth->number, auth->number, auth->number_length)) match = 1; } @@ -101,10 +104,11 @@ entranced_debug("entranced_auth_purge: Write failed!\n"); return; } - - for(li = auth_keep->first; li; li = li->next) + + for (li = auth_keep->first; li; li = li->next) { Xauth *xa; + xa = (Xauth *) li->data; XauWriteAuth(auth_file, (Xauth *) xa); } @@ -119,14 +123,15 @@ * @return A pointer to a new Xauth struct with cookie data, or NULL if * generation failed. */ -Xauth * +Xauth * entranced_auth_mit_get(void) { - Xauth *new; + Xauth *new; new = (Xauth *) malloc(sizeof(Xauth)); - if (!new) return NULL; + if (!new) + return NULL; new->family = FamilyWild; new->address_length = 0; @@ -136,7 +141,7 @@ new->data = (char *) malloc(AUTH_DATA_LEN); new->data_length = AUTH_DATA_LEN; - if(!new->data) + if (!new->data) { free(new); return NULL; @@ -144,8 +149,8 @@ new->name = strdup("MIT-MAGIC-COOKIE-1"); new->name_length = 18; - - if(!entranced_cookie_new(new->data)) + + if (!entranced_cookie_new(new->data)) { free(new->name); free(new->data); @@ -159,7 +164,7 @@ static Xauth * _entranced_auth_generate(void) { - Xauth *auth = NULL; + Xauth *auth = NULL; unsigned short i; auth = entranced_auth_mit_get(); @@ -179,10 +184,10 @@ /* I'm trying to figure out exactly why I added this code */ #if 0 static void -_entranced_auth_number_set(Xauth *auth, char *name) +_entranced_auth_number_set(Xauth * auth, char *name) { - char *colon; - char *dot, *number; + char *colon; + char *dot, *number; colon = strrchr(name, ':'); @@ -202,12 +207,14 @@ } else { - entranced_debug("_entranced_auth_number_set: Yikes, could not allocate memory!\n"); + entranced_debug + ("_entranced_auth_number_set: Yikes, could not allocate memory!\n"); auth->number_length = 0; } auth->number = number; - entranced_debug("_entranced_auth_number_set: %s (successful)\n", number); + entranced_debug("_entranced_auth_number_set: %s (successful)\n", + number); } } #endif @@ -215,24 +222,26 @@ /* This code is needed for authorizing TCP connections */ #if 0 static void -_entranced_auth_name_set(Xauth *auth, const char *hostname) +_entranced_auth_name_set(Xauth * auth, const char *hostname) { - struct hostent *hp; - union { - struct sockaddr sa; - struct sockaddr_in in; + struct hostent *hp; + union + { + struct sockaddr sa; + struct sockaddr_in in; } saddr; - struct sockaddr_in *inetaddr; + struct sockaddr_in *inetaddr; entranced_debug("_entranced_auth_name_set: %s\n", hostname); hp = gethostbyname(hostname); - + if (hp) { saddr.sa.sa_family = hp->h_addrtype; inetaddr = (struct sockaddr_in *) (&(saddr.sa)); - memcpy((char *) &(inetaddr->sin_addr), (char *) hp->h_addr, (int) hp->h_length); + memcpy((char *) &(inetaddr->sin_addr), (char *) hp->h_addr, + (int) hp->h_length); auth->family = FamilyInternet; auth->address_length = sizeof(inetaddr->sin_addr); @@ -249,11 +258,12 @@ } #endif -static int -_entranced_auth_entry_add(Entranced_Display *d, FILE *auth_file, const char *addr, int addrlen) +static int +_entranced_auth_entry_add(Entranced_Display * d, FILE * auth_file, + const char *addr, int addrlen) { - Xauth *auth = NULL; - char dispnum[8]; + Xauth *auth = NULL; + char dispnum[8]; if (!d) return 0; @@ -264,7 +274,7 @@ auth->family = FamilyLocal; auth->address = calloc(1, addrlen); - if(!auth->address) + if (!auth->address) { free(auth); return 0; @@ -280,7 +290,7 @@ return 0; } #endif - + /* Set the display number */ snprintf(dispnum, 8, "%d", d->dispnum); auth->number = strdup(dispnum); @@ -300,7 +310,8 @@ if (!ecore_list_append(d->auths, auth)) { - entranced_debug("_entrance_auth_entry_add: Could not add auth entry to list!\n"); + entranced_debug + ("_entrance_auth_entry_add: Could not add auth entry to list!\n"); return 0; } @@ -309,48 +320,51 @@ } int -entranced_auth_display_secure (Entranced_Display *d) +entranced_auth_display_secure(Entranced_Display * d) { - FILE *auth_file; + FILE *auth_file; + #if 0 - FILE *host_file; + FILE *host_file; #endif - char buf[PATH_MAX]; - char hostname[1024]; + char buf[PATH_MAX]; + char hostname[1024]; if (!d) return 0; umask(022); - entranced_debug("entranced_auth_display_secure: Setting up access for display %s\n", d->name); + entranced_debug + ("entranced_auth_display_secure: Setting up access for display %s\n", + d->name); if (d->authfile) free(d->authfile); /* FIXME: Config-ize */ - snprintf(buf, PATH_MAX, PACKAGE_STATE_DIR"/%s%s", d->name, ".Xauth"); + snprintf(buf, PATH_MAX, PACKAGE_STATE_DIR "/%s%s", d->name, ".Xauth"); d->authfile = strdup(buf); unlink(d->authfile); - if(!(auth_file = fopen(d->authfile, "w"))) + if (!(auth_file = fopen(d->authfile, "w"))) { free(d->authfile); d->authfile = NULL; return 0; } - - /* XXX: This code assumes X server is running on localhost and - * may need to be modified for Xdmcp - */ + + /* XXX: This code assumes X server is running on localhost and may need to + be modified for Xdmcp */ ecore_list_goto_first(d->auths); - while(d->auths->nodes) + while (d->auths->nodes) { Xauth *tmp; + tmp = (Xauth *) ecore_list_remove(d->auths); XauDisposeAuth(tmp); } - + memset(hostname, 0, sizeof(hostname)); if (!gethostname(hostname, 1023)) { @@ -360,50 +374,53 @@ } /* Add auth entry for local host */ - if (!_entranced_auth_entry_add(d, auth_file, d->hostname, - strlen(d->hostname))) + if (!_entranced_auth_entry_add + (d, auth_file, d->hostname, strlen(d->hostname))) return 0; fclose(auth_file); setenv("XAUTHORITY", d->authfile, 1); /* TODO: This will become a config option -- perhaps desirable for - * single-user systems, but not multi-user machines. - * For now it is disabled. - */ + single-user systems, but not multi-user machines. For now it is + disabled. */ #if 0 /* Write host access file */ snprintf(buf, PATH_MAX, "/etc/X%d.hosts", d->dispnum); if (!(host_file = fopen(buf, "w"))) { - entranced_debug("entranced_auth_display_secure: Unable to open %s for writing\n", buf); + entranced_debug + ("entranced_auth_display_secure: Unable to open %s for writing\n", + buf); return 0; } fprintf(host_file, "%s\n", d->hostname); fclose(host_file); #endif - - entranced_debug("entranced_auth_display_secure: Successfully set up access for %s (localhost)\n", d->name); + + entranced_debug + ("entranced_auth_display_secure: Successfully set up access for %s (localhost)\n", + d->name); return 1; } int -entranced_auth_user_add(Entranced_Display *d, const char *homedir) +entranced_auth_user_add(Entranced_Display * d, const char *homedir) { - FILE *auth_file; - int ret = 1; - char buf[PATH_MAX]; - Ecore_List_Node *li; + FILE *auth_file; + int ret = 1; + char buf[PATH_MAX]; + Ecore_List_Node *li; if (!d || !homedir) return 0; entranced_debug("entranced_auth_user_add: Adding auth cookie\n"); - while(1) + while (1) { - umask (077); + umask(077); if (!homedir) d->client.authfile = NULL; @@ -415,30 +432,32 @@ seteuid(d->client.uid); /* Make sure the file can be written to */ - if((auth_file = fopen(d->client.authfile, "a+"))) + if ((auth_file = fopen(d->client.authfile, "a+"))) fclose(auth_file); else { - entranced_debug("entranced_auth_user_add: Unable to write auth file %s\n", d->client.authfile); + entranced_debug + ("entranced_auth_user_add: Unable to write auth file %s\n", + d->client.authfile); free(d->client.authfile); - d->client.authfile = NULL; - seteuid(0); + d->client.authfile = NULL; + seteuid(0); return 0; } /* TODO: May need a permissions/paranoia check */ /* Lock the authorization file */ - /* FIXME: What if for some reason we never succeed in getting - * a lock ? - */ + /* FIXME: What if for some reason we never succeed in getting a lock ? */ if (XauLockAuth(d->client.authfile, 3, 3, 0) != LOCK_SUCCESS) { - syslog(LOG_CRIT, "entranced_auth_user_add: Unable to lock auth file %s", d->client.authfile); + syslog(LOG_CRIT, + "entranced_auth_user_add: Unable to lock auth file %s", + d->client.authfile); free(d->client.authfile); d->client.authfile = NULL; - seteuid(0); - umask (022); + seteuid(0); + umask(022); } else break; @@ -446,27 +465,30 @@ /* Open file and write auth entries */ seteuid(d->client.uid); - if(!(auth_file = fopen(d->client.authfile, "r+"))) + if (!(auth_file = fopen(d->client.authfile, "r+"))) { - syslog(LOG_CRIT, "entranced_auth_user_add: Open auth file %s failed after lock", d->client.authfile); - XauUnlockAuth (d->client.authfile); + syslog(LOG_CRIT, + "entranced_auth_user_add: Open auth file %s failed after lock", + d->client.authfile); + XauUnlockAuth(d->client.authfile); free(d->client.authfile); d->client.authfile = NULL; seteuid(0); - umask (022); + umask(022); return 0; } - entranced_debug("entranced_auth_user_add: Opened %s for writing cookies\n", d->client.authfile); + entranced_debug("entranced_auth_user_add: Opened %s for writing cookies\n", + d->client.authfile); /* Remove any existing old entries for this display */ _entranced_auth_purge(d, auth_file); - + for (li = d->auths->first; li; li = li->next) { - if (!XauWriteAuth (auth_file, (Xauth *) li->data)) + if (!XauWriteAuth(auth_file, (Xauth *) li->data)) { syslog(LOG_CRIT, "entranced_user_auth_add: Unable to write cookie"); ret = 0; @@ -476,25 +498,28 @@ fclose(auth_file); XauUnlockAuth(d->client.authfile); - - /*chown(d->client.authfile, d->client.uid, d->client.gid);*/ - - entranced_debug("entranced_auth_user_add: Finished writing auth entries to %s\n", d->client.authfile); + + /* chown(d->client.authfile, d->client.uid, d->client.gid); */ + + entranced_debug + ("entranced_auth_user_add: Finished writing auth entries to %s\n", + d->client.authfile); seteuid(0); - + return ret; - + } void -entranced_auth_user_remove (Entranced_Display *d) +entranced_auth_user_remove(Entranced_Display * d) { - FILE *auth_file; + FILE *auth_file; if (!d || !d->client.authfile) return; - entranced_debug("entranced_auth_user_remove: Removing cookie from %s\n", d->client.authfile); + entranced_debug("entranced_auth_user_remove: Removing cookie from %s\n", + d->client.authfile); /* TODO: Permissions check on auth file */ /* Get a lock */ @@ -516,7 +541,7 @@ /* Remove cookies for this display */ _entranced_auth_purge(d, auth_file); - + /* Close and unlock */ fclose(auth_file); XauUnlockAuth(d->client.authfile); @@ -524,5 +549,3 @@ free(d->client.authfile); d->client.authfile = NULL; } - - =================================================================== RCS file: /cvs/e/e17/apps/entrance/src/daemon/entranced_display.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- entranced_display.c 26 Sep 2006 18:50:29 -0000 1.4 +++ entranced_display.c 26 Oct 2006 08:05:56 -0000 1.5 @@ -65,7 +65,7 @@ * @param d The spawner display context that this session will use */ void -edd_spawn_entrance(Entranced_Display *d) +edd_spawn_entrance(Entranced_Display * d) { char entrance_cmd[PATH_MAX]; @@ -78,12 +78,12 @@ snprintf(entrance_cmd, PATH_MAX, "%s -d %s", ENTRANCE, d->name); if (d->config) - snprintf(entrance_cmd, PATH_MAX, "%s -d %s -c \"%s\" -z %d", - ENTRANCE, d->name, d->config, getpid()); + snprintf(entrance_cmd, PATH_MAX, "%s -d %s -c \"%s\" -z %d", ENTRANCE, + d->name, d->config, getpid()); else snprintf(entrance_cmd, PATH_MAX, "%s -d %s -z %d", ENTRANCE, d->name, - getpid()); - /*printf("Starting command: %s\n", entrance_cmd);*/ + getpid()); + /* printf("Starting command: %s\n", entrance_cmd); */ d->e_exe = ecore_exe_run(entrance_cmd, d); d->client.pid = ecore_exe_pid_get(d->e_exe); } @@ -106,10 +106,10 @@ return 1; } -void +void edd_x_ready_set(unsigned char i) { - x_ready = i; + x_ready = i; } /*privates*/ @@ -119,15 +119,17 @@ * @return The status of the display context after the launch attempt */ static pid_t -_start_server_once(Entranced_Display * d) /*seems private*/ +_start_server_once(Entranced_Display * d) /* seems + private */ { double start_time; char x_cmd[PATH_MAX]; int i; - char *x_cmd_argv[32]; + char *x_cmd_argv[32]; - for (i=0;i<32;i++) x_cmd_argv[i]=NULL; + for (i = 0; i < 32; i++) + x_cmd_argv[i] = NULL; /* Ecore_Exe *x_exe; */ pid_t xpid; @@ -138,15 +140,16 @@ /* Create server auth cookie */ - if(d->auth_en) + if (d->auth_en) { if (!entranced_auth_display_secure(d)) { syslog(LOG_CRIT, "Failed to generate auth cookie for X Server."); return -1; } - - snprintf(x_cmd, PATH_MAX, "%s -auth %s %s", d->xprog, d->authfile, d->name); + + snprintf(x_cmd, PATH_MAX, "%s -auth %s %s", d->xprog, d->authfile, + d->name); } else { @@ -166,12 +169,13 @@ sigemptyset(&_entrance_x_sa.sa_mask); sigaction(SIGUSR1, &_entrance_x_sa, NULL); - x_cmd_argv[0]=strtok(x_cmd," "); - i=1; + x_cmd_argv[0] = strtok(x_cmd, " "); + i = 1; - while ((x_cmd_argv[i]=strtok(NULL," "))!=NULL) { - i++; - } + while ((x_cmd_argv[i] = strtok(NULL, " ")) != NULL) + { + i++; + } execvp(x_cmd_argv[0], x_cmd_argv); syslog(LOG_WARNING, "Could not execute X server."); @@ -186,12 +190,13 @@ usleep(100000); current_time = ecore_time_get(); if ((current_time - start_time) > 5.0) - break; + break; } if (!x_ready) { - entranced_debug("Entranced_Start_Server_Once: Attempt to start X server failed.\n"); + entranced_debug + ("Entranced_Start_Server_Once: Attempt to start X server failed.\n"); d->status = NOT_RUNNING; } else =================================================================== RCS file: /cvs/e/e17/apps/entrance/src/daemon/ipc.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- ipc.c 3 Jun 2006 06:36:16 -0000 1.8 +++ ipc.c 26 Oct 2006 08:05:56 -0000 1.9 @@ -44,46 +44,55 @@ if (!(e = (Ecore_Ipc_Event_Client_Data *) event) || !_display) return 1; - /* FIXME: This assumes there is only one client ... client will - * need to pass its pid or other verification data in the - * case of multiple clients (XDMCP) - */ + /* FIXME: This assumes there is only one client ... client will need to + pass its pid or other verification data in the case of multiple clients + (XDMCP) */ if (e->major == E_XAUTH_REQ) { switch (e->minor) { - case E_UID: - _display->client.uid = e->response; - break; - case E_GID: - _display->client.gid = e->response; - break; - case E_HOMEDIR: - _display->client.homedir = strdup(e->data); - break; - default: - syslog(LOG_WARNING, "Received invalid request %x from client %d", - e->minor, _display->client.pid); + case E_UID: + _display->client.uid = e->response; + break; + case E_GID: + _display->client.gid = e->response; + break; + case E_HOMEDIR: + _display->client.homedir = strdup(e->data); + break; + default: + syslog(LOG_WARNING, "Received invalid request %x from client %d", + e->minor, _display->client.pid); } if ((_display->client.uid >= 0) && (_display->client.gid >= 0) - && (_display->client.homedir)) + && (_display->client.homedir)) { - if (!(_display->auth_en) || entranced_auth_user_add(_display, (const char *)_display->client.homedir)) + if (!(_display->auth_en) + || entranced_auth_user_add(_display, + (const char *) _display->client. + homedir)) { - ecore_ipc_client_send(e->client, E_XAUTH_ACK, 0, 0, 0, 0, NULL, 0); - entranced_debug("_entranced_ipc_client_data: All tokens received; wrote cookie to user dir %s\n", _display->client.homedir); + ecore_ipc_client_send(e->client, E_XAUTH_ACK, 0, 0, 0, 0, NULL, + 0); + entranced_debug + ("_entranced_ipc_client_data: All tokens received; wrote cookie to user dir %s\n", + _display->client.homedir); } else { - ecore_ipc_client_send(e->client, E_XAUTH_NAK, 0, 0, 0, 0, NULL, 0); - entranced_debug("_entranced_ipc_client_data: Failed to write cookie to %s\n", _display->client.homedir); + ecore_ipc_client_send(e->client, E_XAUTH_NAK, 0, 0, 0, 0, NULL, + 0); + entranced_debug + ("_entranced_ipc_client_data: Failed to write cookie to %s\n", + _display->client.homedir); } } } - entranced_debug("_entranced_ipc_client_data: Received [%i] [%i] [%i] [%i] \"%s\"\n", - e->major, e->minor, e->size, e->response, (char *) e->data); + entranced_debug + ("_entranced_ipc_client_data: Received [%i] [%i] [%i] [%i] \"%s\"\n", + e->major, e->minor, e->size, e->response, (char *) e->data); return 1; } @@ -100,7 +109,7 @@ ecore_file_mkpath(PACKAGE_STATE_DIR); memset(buf, 0, sizeof(buf)); - snprintf(buf, PATH_MAX, "%s_%d", PACKAGE_STATE_DIR"/"IPC_TITLE, pid); + snprintf(buf, PATH_MAX, "%s_%d", PACKAGE_STATE_DIR "/" IPC_TITLE, pid); if (ipc_title) free(ipc_title); ipc_title = strdup(buf); @@ -111,10 +120,13 @@ _entranced_ipc_client_del, NULL); ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, _entranced_ipc_client_data, NULL); - - if (!(server = ecore_ipc_server_add(ECORE_IPC_LOCAL_SYSTEM, ipc_title, 0, NULL))) + + if (! + (server = + ecore_ipc_server_add(ECORE_IPC_LOCAL_SYSTEM, ipc_title, 0, NULL))) { - entranced_debug("entranced_ipc_init: Failed to open socket %s.\n", ipc_title); + entranced_debug("entranced_ipc_init: Failed to open socket %s.\n", + ipc_title); return 0; } @@ -123,27 +135,27 @@ clients = ecore_list_new(); entranced_debug("entranced_ipc_init: Success\n"); - + return 1; } void entranced_ipc_shutdown(void) { - if(clients) + if (clients) ecore_list_destroy(clients); clients = NULL; - + ecore_ipc_shutdown(); - if(ipc_title) + if (ipc_title) free(ipc_title); ipc_title = NULL; - + entranced_debug("entranced_ipc_shutdown: Success\n"); } -void entranced_ipc_display_set(Entranced_Display *d) +void +entranced_ipc_display_set(Entranced_Display * d) { _display = d; } - =================================================================== RCS file: /cvs/e/e17/apps/entrance/src/daemon/md5.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- md5.c 16 Aug 2005 04:04:04 -0000 1.3 +++ md5.c 26 Oct 2006 08:05:56 -0000 1.4 @@ -1,24 +1,29 @@ #include <stdlib.h> -#include <string.h> /* for memcpy() */ +#include <string.h> /* for memcpy() */ #include "md5.h" #if (__BYTE_ORDER == 1234) -#define byteReverse(buf, len) /* Nothing */ +#define byteReverse(buf, len) /* Nothing */ #else void byteReverse(unsigned char *buf, unsigned longs); /* * Note: this code is harmless on little-endian machines. */ -void byteReverse(unsigned char *buf, unsigned longs) +void +byteReverse(unsigned char *buf, unsigned longs) { - u_int32_t t; - do { - t = (u_int32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(u_int32_t *) buf = t; - buf += 4; - } while (--longs); + u_int32_t t; + + do + { + t = (u_int32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) + buf[1] << 8 | + buf[0]); + *(u_int32_t *) buf = t; + buf += 4; + } + while (--longs); } #endif @@ -26,111 +31,125 @@ * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ -void entranced_md5_init(Entranced_MD5_Context **ctx) +void +entranced_md5_init(Entranced_MD5_Context ** ctx) { - if (!(*ctx)) - *ctx = malloc(sizeof(Entranced_MD5_Context)); - - (*ctx)->buf[0] = 0x67452301; - (*ctx)->buf[1] = 0xefcdab89; - (*ctx)->buf[2] = 0x98badcfe; - (*ctx)->buf[3] = 0x10325476; + if (!(*ctx)) + *ctx = malloc(sizeof(Entranced_MD5_Context)); + + (*ctx)->buf[0] = 0x67452301; + (*ctx)->buf[1] = 0xefcdab89; + (*ctx)->buf[2] = 0x98badcfe; + (*ctx)->buf[3] = 0x10325476; - (*ctx)->bits[0] = 0; - (*ctx)->bits[1] = 0; + (*ctx)->bits[0] = 0; + (*ctx)->bits[1] = 0; } /* * Update context to reflect the concatenation of another buffer full * of bytes. */ -void entranced_md5_update(Entranced_MD5_Context *ctx, unsigned char const *buf, unsigned len) +void +entranced_md5_update(Entranced_MD5_Context * ctx, unsigned char const *buf, + unsigned len) { - u_int32_t t; + u_int32_t t; - /* Update bitcount */ + /* Update bitcount */ - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((u_int32_t) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; - - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - - /* Handle any leading odd-sized chunks */ - - if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - byteReverse(ctx->in, 16); - entranced_md5_transform(ctx->buf, (u_int32_t *) ctx->in); - buf += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) { - memcpy(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - entranced_md5_transform(ctx->buf, (u_int32_t *) ctx->in); - buf += 64; - len -= 64; - } + t = ctx->bits[0]; + if ((ctx->bits[0] = t + ((u_int32_t) len << 3)) < t) + ctx->bits[1]++; /* Carry from low to high */ + ctx->bits[1] += len >> 29; + + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + + /* Handle any leading odd-sized chunks */ + + if (t) + { + unsigned char *p = (unsigned char *) ctx->in + t; + + t = 64 - t; + if (len < t) + { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + byteReverse(ctx->in, 16); + entranced_md5_transform(ctx->buf, (u_int32_t *) ctx->in); + buf += t; + len -= t; + } + /* Process data in 64-byte chunks */ + + while (len >= 64) + { + memcpy(ctx->in, buf, 64); + byteReverse(ctx->in, 16); + entranced_md5_transform(ctx->buf, (u_int32_t *) ctx->in); + buf += 64; + len -= 64; + } - /* Handle any remaining bytes of data. */ + /* Handle any remaining bytes of data. */ - memcpy(ctx->in, buf, len); + memcpy(ctx->in, buf, len); } /* * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ -void entranced_md5_final(unsigned char digest[16], Entranced_MD5_Context *ctx) +void +entranced_md5_final(unsigned char digest[16], Entranced_MD5_Context * ctx) { - unsigned count; - unsigned char *p; + unsigned count; + unsigned char *p; - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; + /* Compute number of bytes mod 64 */ + count = (ctx->bits[0] >> 3) & 0x3F; - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in + count; - *p++ = 0x80; - - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; - - /* Pad out to 56 mod 64 */ - if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - byteReverse(ctx->in, 16); - entranced_md5_transform(ctx->buf, (u_int32_t *) ctx->in); - - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); - } else { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); - } - byteReverse(ctx->in, 14); - - /* Append length in bits and transform */ - ((u_int32_t *) ctx->in)[14] = ctx->bits[0]; - ((u_int32_t *) ctx->in)[15] = ctx->bits[1]; - - entranced_md5_transform(ctx->buf, (u_int32_t *) ctx->in); - byteReverse((unsigned char *) ctx->buf, 4); - memcpy(digest, ctx->buf, 16); - memset((char *) ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + /* Set the first char of padding to 0x80. This is safe since there is + always at least one byte free */ + p = ctx->in + count; + *p++ = 0x80; + + /* Bytes of padding needed to make 64 bytes */ + count = 64 - 1 - count; + + /* Pad out to 56 mod 64 */ + if (count < 8) + { + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + byteReverse(ctx->in, 16); + entranced_md5_transform(ctx->buf, (u_int32_t *) ctx->in); + + /* Now fill the next block with 56 bytes */ + memset(ctx->in, 0, 56); + } + else + { + /* Pad block to 56 bytes */ + memset(p, 0, count - 8); + } + byteReverse(ctx->in, 14); + + /* Append length in bits and transform */ + ((u_int32_t *) ctx->in)[14] = ctx->bits[0]; + ((u_int32_t *) ctx->in)[15] = ctx->bits[1]; + + entranced_md5_transform(ctx->buf, (u_int32_t *) ctx->in); + byteReverse((unsigned char *) ctx->buf, 4); + memcpy(digest, ctx->buf, 16); + memset((char *) ctx, 0, sizeof(ctx)); /* In + case + it's + sensitive + */ } /* The four core functions - F1 is optimized somewhat */ @@ -150,85 +169,86 @@ * reflect the addition of 16 longwords of new data. MD5Update blocks * the data and converts bytes into longwords for this routine. */ -void entranced_md5_transform(u_int32_t buf[4], u_int32_t const in[16]) +void +entranced_md5_transform(u_int32_t buf[4], u_int32_t const in[16]) { - register u_int32_t a, b, c, d; + register u_int32_t a, b, c, d; - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; } =================================================================== RCS file: /cvs/e/e17/apps/entrance/src/daemon/spawner.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -3 -r1.35 -r1.36 --- spawner.c 1 Aug 2006 05:30:58 -0000 1.35 +++ spawner.c 26 Oct 2006 08:05:56 -0000 1.36 @@ -23,37 +23,38 @@ static int _timer_cb_respawn_reset(void *); -static void * _filter_cb_start(void *); -static int _filter_cb_loop(void *, void *, int , void *); +static void *_filter_cb_start(void *); +static int _filter_cb_loop(void *, void *, int, void *); static void _filter_cb_end(void *, void *); static void _sigaction_cb_sigusr(int); -static int _event_cb_exited(void *, int , void *); -static int _event_cb_signal_exit(void *, int , void *); +static int _event_cb_exited(void *, int, void *); +static int _event_cb_signal_exit(void *, int, void *); static void _cb_atexit(void); -void usage(char* name) +void +usage(char *name) { /* This should probably in a separate usage function, but bleh */ printf("Entranced - Launcher for the Entrance Display Manager\n"); printf("Usage: %s [OPTION] ...\n\n", name); printf - ("--------------------------------------------------------------------------\n"); + ("--------------------------------------------------------------------------\n"); printf(" -c CONFIG Specify config file for greeter\n"); printf(" -d DISPLAY Connect to an existing X server\n"); printf(" -help Display this help message\n"); - /*printf(" -verbose Display extra debugging info\n");*/ + /* printf(" -verbose Display extra debugging info\n"); */ printf - (" -nodaemon Don't fork to background (useful for init scripts)\n"); + (" -nodaemon Don't fork to background (useful for init scripts)\n"); printf - ("==========================================================================\n\n"); + ("==========================================================================\n\n"); printf - ("Note: if you're launching Entrance from within an existing X session, don't\n"); + ("Note: if you're launching Entrance from within an existing X session, don't\n"); printf - ("try to use entranced or you may get unexpected results. Instead, launch\n"); + ("try to use entranced or you may get unexpected results. Instead, launch\n"); printf("entrance directly by typing \"entrance\".\n\n"); exit(0); } @@ -116,19 +117,18 @@ nodaemon = 1; break; case 'h': - usage(argv[0]); - /*case 'v': - config.debuglevel = 1;*/ + usage(argv[0]); + /* case 'v': config.debuglevel = 1; */ } } if (!d->name) d->name = strdup(X_DISP); - + str = strstr(d->name, ":"); - if(!str || str >= (d->name + strlen(d->name) - 1)) + if (!str || str >= (d->name + strlen(d->name) - 1)) d->dispnum = 0; else d->dispnum = atoi(str + 1); @@ -167,11 +167,8 @@ if (!nodaemon) { /* This causes socket communication issues, yet unidentified */ - /* - close(0); - close(1); - close(2); - */ + /* + close(0); close(1); close(2); */ freopen("/dev/null", "r", stdin); freopen("/dev/null", "w", stdout); freopen("/dev/null", "w", stderr); @@ -204,7 +201,8 @@ { free(d); syslog(LOG_CRIT, "Could not start X server."); - fprintf(stderr, "Entrance could not start the X server. Please check your config.\n"); + fprintf(stderr, + "Entrance could not start the X server. Please check your config.\n"); exit(1); } @@ -374,9 +372,10 @@ if (!d->client.connected) { syslog(LOG_CRIT, "Entrance GUI initialization failure. Aborting."); - fprintf(stderr, "Entrance has detected that the GUI is failing to launch properly.\n"); + fprintf(stderr, + "Entrance has detected that the GUI is failing to launch properly.\n"); fprintf(stderr, "Please check your installation. Aborting.\n\n"); - ecore_main_loop_quit(); + ecore_main_loop_quit(); } /* Session exited or crashed */ @@ -419,7 +418,7 @@ exit(1); } - else + else { return 1; } =================================================================== RCS file: /cvs/e/e17/apps/entrance/src/daemon/util.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- util.c 1 Aug 2006 04:38:19 -0000 1.2 +++ util.c 26 Oct 2006 08:05:56 -0000 1.3 @@ -3,18 +3,19 @@ /* extern Entranced_Config config; */ -void entranced_debug (char *fmt, ...) +void +entranced_debug(char *fmt, ...) { /* if (config.debuglevel > 0) */ #ifdef DEBUG if (ENTRANCED_DEBUG) { va_list args; - va_start (args, fmt); + + va_start(args, fmt); vprintf(fmt, args); va_end(args); fflush(stdout); } #endif } - ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs