Enlightenment CVS committal
Author : xcomputerman
Project : e17
Module : apps/entrance
Dir : e17/apps/entrance/src/daemon
Modified Files:
auth.c auth.h
Log Message:
Entranced code cleanup patch from Morten Nilsen.
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/daemon/auth.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- auth.c 5 Sep 2005 12:05:57 -0000 1.18
+++ auth.c 7 Nov 2005 18:41:11 -0000 1.19
@@ -17,7 +17,8 @@
#define AUTH_DATA_LEN 16
-char * entranced_cookie_new (void)
+int
+entranced_cookie_new (char *cookie)
{
int fd;
int r;
@@ -25,7 +26,6 @@
unsigned char digest[MD5_HASHBYTES];
double ctime;
pid_t pid;
- char *cookie;
Entranced_MD5_Context *ctx = NULL;
entranced_md5_init(&ctx);
@@ -38,30 +38,24 @@
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");
- return NULL;
+ 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");
- return NULL;
+ return 0;
}
entranced_md5_update(ctx, buf, r);
entranced_md5_final(digest, ctx);
- cookie = calloc(1, 16);
-#if 0
- for (i = 0; i < MD5_HASHBYTES; ++i) {
- char tmp[3];
- snprintf(tmp, sizeof(tmp), "%02x", (unsigned int) digest[i]);
- strcat(cookie, tmp);
- }
-#endif
-
memcpy(cookie, digest, MD5_HASHBYTES);
- return cookie;
+
+ return 1;
}
static void
@@ -129,7 +123,6 @@
entranced_auth_mit_get(void)
{
Xauth *new;
- char *cookie;
new = (Xauth *) malloc(sizeof(Xauth));
@@ -142,28 +135,24 @@
new->number = 0;
new->data = (char *) malloc(AUTH_DATA_LEN);
+ new->data_length = AUTH_DATA_LEN;
if(!new->data)
{
free(new);
return NULL;
}
-
+
new->name = strdup("MIT-MAGIC-COOKIE-1");
new->name_length = 18;
- cookie = entranced_cookie_new();
- if (!cookie)
+
+ if(!entranced_cookie_new(new->data))
{
free(new->name);
free(new->data);
free(new);
return NULL;
}
-
- memcpy(new->data, cookie, AUTH_DATA_LEN);
- new->data_length = AUTH_DATA_LEN;
- free(cookie);
-
return new;
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/daemon/auth.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- auth.h 23 Mar 2004 00:29:43 -0000 1.1
+++ auth.h 7 Nov 2005 18:41:11 -0000 1.2
@@ -5,7 +5,7 @@
#include <X11/Xauth.h>
#include <X11/Xos.h>
-char *entranced_cookie_new(void);
+int entranced_cookie_new(char *cookie);
Xauth *entranced_auth_mit_get(void);
int entranced_auth_display_secure(Entranced_Display *d);
int entranced_auth_user_add(Entranced_Display *d, const char *homedir);
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs