Permalink
Browse files

key system in place

  • Loading branch information...
1 parent da6e7d4 commit 24073f0ea64b98cd696e1b75a0f6f0f423381869 @nickbjohnson4224 committed Jan 31, 2012
View
@@ -136,6 +136,7 @@ int main(int argc, char **argv) {
rdi_init();
term = rdi_file_cons(robject_new_index(), ACCS_READ | ACCS_WRITE);
+
robject_set_data(term, "type", (void*) "term");
if (argc < 3) {
View
@@ -68,8 +68,8 @@ int main(int argc, char **argv) {
rdi_global_write_hook = serial_write;
// daemonize
- msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
- _done();
+ msendb(getppid(), ACTION_CHILD);
+ done();
return 0;
}
View
@@ -105,9 +105,9 @@ int fish_exec_fg(int argc, char **argv, FILE *in, FILE *out, FILE *err) {
abort();
}
}
- frcall(stdout->fd, AC_ROOT, "set_fgjob %d", pid);
+ frcall(stdout->fd, AC_WRITE, "set_fgjob %d", pid);
waitpid(pid, NULL, 0);
- frcall(stdout->fd, AC_ROOT, "set_fgjob %d", 0);
+ frcall(stdout->fd, AC_WRITE, "set_fgjob %d", 0);
return 0;
}
View
@@ -41,12 +41,12 @@ struct fb *fb_cons(uint64_t rp) {
// allocate and setup framebuffer
fb = malloc(sizeof(struct fb));
- fb->fd = ropen(-1, rp, ACCS_WRITE);
+ fb->fd = ropen(-1, rp, ACCS_READ | ACCS_WRITE);
fb->mutex = false;
fb->flags = 0;
// check video mode
- mode = rcall(rp, 0, "getmode");
+ mode = frcall(fb->fd, AC_READ, "getmode");
if (!mode) {
close(fb->fd);
View
@@ -46,8 +46,8 @@ int fb_flip(struct fb *fb) {
if (fb->flags & FB_SHARED) {
// shared: just sync
- ret = rcall(fd_rp(fb->fd), 0, "syncrect %d %d %d %d", fb->minx, fb->miny,
- fb->maxx - fb->minx, fb->maxy - fb->miny);
+ ret = frcall(fb->fd, AC_WRITE, "syncrect %d %d %d %d",
+ fb->minx, fb->miny, fb->maxx - fb->minx, fb->maxy - fb->miny);
if (!ret || !strcmp(ret, "")) {
mutex_free(&fb->mutex);
return 1;
View
@@ -83,7 +83,7 @@ rp_t ator(const char *str);
int fd_alloc(void);
int fd_set (int fd, rp_t rp, int mode);
-int fd_pullkey(int fd);
+int fd_genkeys(int fd);
rk_t fd_getkey (int fd, int action);
int fd_mode (int fd);
rp_t fd_rp (int fd);
@@ -165,7 +165,7 @@ int dup2 (int fd, int newfd);
* The action class for administrative actions pertaining to the driver
* itself. Generally very driver-specific.
*
- * Example actions: power-down, hard-reset
+ * Example actions: set-fg, power-down, hard-reset
*/
#define AC_NULL 0
@@ -185,8 +185,7 @@ int dup2 (int fd, int newfd);
* performed on a resource.
*/
-rk_t rp_getkey (rp_t rp, int action);
-int rp_getkeys(rp_t rp, rk_t keys[8]);
+rk_t rp_getkey(rp_t rp, int action);
/*****************************************************************************
* Resource Access Control Lists
@@ -223,8 +222,11 @@ int rp_getkeys(rp_t rp, rk_t keys[8]);
#define ACCS_READ (1 << AC_READ)
#define ACCS_WRITE (1 << AC_WRITE)
+#define ACCS_ALTER (1 << AC_ALTER)
#define ACCS_ADMIN (1 << AC_ADMIN)
#define ACCS_EVENT (1 << AC_EVENT)
+#define ACCS_LOCK (1 << AC_LOCK)
+#define ACCS_ROOT (1 << AC_ROOT)
int rp_access(rp_t rp, uint32_t user);
int rp_admin (rp_t rp, uint32_t user, int access);
View
@@ -58,7 +58,7 @@ int rp_ulink(rp_t dir, const char *name) {
return 1;
}
- reply = rcall(dir, 0, "unlink %s", name);
+ reply = rcall(dir, rp_getkey(dir, AC_ALTER), "unlink %s", name);
if (iserror(reply)) {
errno = geterror(reply);
@@ -99,7 +99,7 @@ int rp_link(uint64_t dir, const char *name, uint64_t link) {
return 1;
}
- reply = rcall(dir, 0, "link %s %r", name, link);
+ reply = rcall(dir, rp_getkey(dir, AC_ALTER), "link %s %r", name, link);
if (iserror(reply)) {
errno = geterror(reply);
View
@@ -85,7 +85,7 @@ int fd_set(int fd, rp_t rp, int mode) {
return 0;
}
-int fd_pullkey(int fd) {
+int fd_genkeys(int fd) {
if (fd < 0 || fd >= _fdtab_size) {
// file descriptor out of range
View
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Nick Johnson <nickbjohnson4224 at gmail.com>
+ * Copyright (C) 2011-2012 Nick Johnson <nickbjohnson4224 at gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* 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) {
return -1;
}
- fd_pullkey(fd);
+ fd_genkeys(fd);
if (mode & ACCS_EVENT) {
// register for events
View
@@ -40,8 +40,8 @@ struct robject *robject_cons(uint32_t index, struct robject *parent) {
// generate random keys
// XXX SEC - this should be replaced with a secure RNG ASAP
- srand(time(NULL) + index + (uint32_t) parent + (uint32_t) robject);
- for (int i = 0; i < 8; i++) {
+ robject->key[0] = 0ULL;
+ for (int i = 1; i < 8; i++) {
robject->key[i] = (uint64_t) rand() | (uint64_t) rand() << 32ULL;
}
View
@@ -125,7 +125,6 @@ char *robject_call(struct robject *ro, rp_t source, rk_t key, const char *args)
return errorstr(ENOSYS);
}
-#ifdef KEYSEC
if (source) {
// get call action class
@@ -134,11 +133,10 @@ char *robject_call(struct robject *ro, rp_t source, rk_t key, const char *args)
mutex_free(&ro->mutex);
// check key
- if (class > 8 || key != ro->key[class]) {
+ if (class != 0 && (class > 8 || key != ro->key[class])) {
return errorstr(EACCES);
}
}
-#endif
rets = call(ro, source, argc, argv);

0 comments on commit 24073f0

Please sign in to comment.