Skip to content
This repository
Browse code

key system in place

  • Loading branch information...
commit 24073f0ea64b98cd696e1b75a0f6f0f423381869 1 parent da6e7d4
Nick Johnson authored January 30, 2012
1  driver/biterm/main.c
@@ -136,6 +136,7 @@ int main(int argc, char **argv) {
136 136
 	rdi_init();
137 137
 
138 138
 	term = rdi_file_cons(robject_new_index(), ACCS_READ | ACCS_WRITE);
  139
+	
139 140
 	robject_set_data(term, "type", (void*) "term");
140 141
 
141 142
 	if (argc < 3) {
4  driver/serial/main.c
@@ -68,8 +68,8 @@ int main(int argc, char **argv) {
68 68
 	rdi_global_write_hook = serial_write;
69 69
 	
70 70
 	// daemonize
71  
-	msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
72  
-	_done();
  71
+	msendb(getppid(), ACTION_CHILD);
  72
+	done();
73 73
 
74 74
 	return 0;
75 75
 }
4  fish/main.c
@@ -105,9 +105,9 @@ int fish_exec_fg(int argc, char **argv, FILE *in, FILE *out, FILE *err) {
105 105
 			abort();
106 106
 		}
107 107
 	}
108  
-	frcall(stdout->fd, AC_ROOT, "set_fgjob %d", pid);
  108
+	frcall(stdout->fd, AC_WRITE, "set_fgjob %d", pid);
109 109
 	waitpid(pid, NULL, 0);
110  
-	frcall(stdout->fd, AC_ROOT, "set_fgjob %d", 0);
  110
+	frcall(stdout->fd, AC_WRITE, "set_fgjob %d", 0);
111 111
 	
112 112
 	return 0;
113 113
 }
4  libc/graph/fb_cons.c
@@ -41,12 +41,12 @@ struct fb *fb_cons(uint64_t rp) {
41 41
 
42 42
 	// allocate and setup framebuffer
43 43
 	fb = malloc(sizeof(struct fb));
44  
-	fb->fd    = ropen(-1, rp, ACCS_WRITE);
  44
+	fb->fd    = ropen(-1, rp, ACCS_READ | ACCS_WRITE);
45 45
 	fb->mutex = false;
46 46
 	fb->flags = 0;
47 47
 	
48 48
 	// check video mode
49  
-	mode = rcall(rp, 0, "getmode");
  49
+	mode = frcall(fb->fd, AC_READ, "getmode");	
50 50
 
51 51
 	if (!mode) {
52 52
 		close(fb->fd);
4  libc/graph/fb_flip.c
@@ -46,8 +46,8 @@ int fb_flip(struct fb *fb) {
46 46
 
47 47
 	if (fb->flags & FB_SHARED) {
48 48
 		// shared: just sync
49  
-		ret = rcall(fd_rp(fb->fd), 0, "syncrect %d %d %d %d", fb->minx, fb->miny, 
50  
-			fb->maxx - fb->minx, fb->maxy - fb->miny);
  49
+		ret = frcall(fb->fd, AC_WRITE, "syncrect %d %d %d %d",
  50
+			fb->minx, fb->miny, fb->maxx - fb->minx, fb->maxy - fb->miny);
51 51
 		if (!ret || !strcmp(ret, "")) {
52 52
 			mutex_free(&fb->mutex);
53 53
 			return 1;
10  libc/inc/rhombus.h
@@ -83,7 +83,7 @@ rp_t ator(const char *str);
83 83
 
84 84
 int  fd_alloc(void);
85 85
 int  fd_set    (int fd, rp_t rp, int mode);
86  
-int  fd_pullkey(int fd);
  86
+int  fd_genkeys(int fd);
87 87
 rk_t fd_getkey (int fd, int action);
88 88
 int  fd_mode   (int fd);
89 89
 rp_t fd_rp     (int fd);
@@ -165,7 +165,7 @@ int dup2 (int fd, int newfd);
165 165
  *   The action class for administrative actions pertaining to the driver
166 166
  *   itself. Generally very driver-specific.
167 167
  *
168  
- *   Example actions: power-down, hard-reset
  168
+ *   Example actions: set-fg, power-down, hard-reset
169 169
  */
170 170
 
171 171
 #define AC_NULL  0
@@ -185,8 +185,7 @@ int dup2 (int fd, int newfd);
185 185
  * performed on a resource.
186 186
  */
187 187
 
188  
-rk_t rp_getkey (rp_t rp, int action);
189  
-int  rp_getkeys(rp_t rp, rk_t keys[8]);
  188
+rk_t rp_getkey(rp_t rp, int action);
190 189
 
191 190
 /*****************************************************************************
192 191
  * Resource Access Control Lists
@@ -223,8 +222,11 @@ int  rp_getkeys(rp_t rp, rk_t keys[8]);
223 222
 
224 223
 #define ACCS_READ  (1 << AC_READ)
225 224
 #define ACCS_WRITE (1 << AC_WRITE)
  225
+#define ACCS_ALTER (1 << AC_ALTER)
226 226
 #define ACCS_ADMIN (1 << AC_ADMIN)
227 227
 #define ACCS_EVENT (1 << AC_EVENT)
  228
+#define ACCS_LOCK  (1 << AC_LOCK)
  229
+#define ACCS_ROOT  (1 << AC_ROOT)
228 230
 
229 231
 int rp_access(rp_t rp, uint32_t user);
230 232
 int rp_admin (rp_t rp, uint32_t user, int access);
4  libc/natio/fs_link.c
@@ -58,7 +58,7 @@ int rp_ulink(rp_t dir, const char *name) {
@@ -99,7 +99,7 @@ int rp_link(uint64_t dir, const char *name, uint64_t link) {
2  libc/rhombus/fdtab.c
@@ -85,7 +85,7 @@ int fd_set(int fd, rp_t rp, int mode) {
85 85
 	return 0;
86 86
 }
87 87
 
88  
-int fd_pullkey(int fd) {
  88
+int fd_genkeys(int fd) {
89 89
 
90 90
 	if (fd < 0 || fd >= _fdtab_size) {
91 91
 		// file descriptor out of range
4  libc/rhombus/ropen.c
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2  
- * Copyright (C) 2011 Nick Johnson <nickbjohnson4224 at gmail.com>
  2
+ * Copyright (C) 2011-2012 Nick Johnson <nickbjohnson4224 at gmail.com>
3 3
  * 
4 4
  * Permission to use, copy, modify, and distribute this software for any
5 5
  * purpose with or without fee is hereby granted, provided that the above
@@ -49,7 +49,7 @@ int ropen(int fd, rp_t rp, int mode) {
49 49
 		return -1;
50 50
 	}
51 51
 
52  
-	fd_pullkey(fd);
  52
+	fd_genkeys(fd);
53 53
 
54 54
 	if (mode & ACCS_EVENT) {
55 55
 		// register for events
4  librdi/robject/cons.c
@@ -40,8 +40,8 @@ struct robject *robject_cons(uint32_t index, struct robject *parent) {
40 40
 
41 41
 	// generate random keys
42 42
 	// XXX SEC - this should be replaced with a secure RNG ASAP
43  
-	srand(time(NULL) + index + (uint32_t) parent + (uint32_t) robject);
44  
-	for (int i = 0; i < 8; i++) {
  43
+	robject->key[0] = 0ULL;
  44
+	for (int i = 1; i < 8; i++) {
45 45
 		robject->key[i] = (uint64_t) rand() | (uint64_t) rand() << 32ULL;
46 46
 	}
47 47
 
4  librdi/robject/robject.c
@@ -125,7 +125,6 @@ char *robject_call(struct robject *ro, rp_t source, rk_t key, const char *args)
125 125
 		return errorstr(ENOSYS);
126 126
 	}
127 127
 
128  
-#ifdef KEYSEC
129 128
 	if (source) {
130 129
 
131 130
 		// get call action class
@@ -134,11 +133,10 @@ char *robject_call(struct robject *ro, rp_t source, rk_t key, const char *args)
134 133
 		mutex_free(&ro->mutex);
135 134
 
136 135
 		// check key
137  
-		if (class > 8 || key != ro->key[class]) {
  136
+		if (class != 0 && (class > 8 || key != ro->key[class])) {
138 137
 			return errorstr(EACCES);
139 138
 		}
140 139
 	}
141  
-#endif
142 140
 
143 141
 	rets = call(ro, source, argc, argv);
144 142
 

0 notes on commit 24073f0

Please sign in to comment.
Something went wrong with that request. Please try again.