]> Zhao Yanbai Git Server - minix.git/commitdiff
Allow servers to run with fewer privileges:
authorDavid van Moolenbroek <david@minix3.org>
Wed, 2 Dec 2009 10:06:58 +0000 (10:06 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Wed, 2 Dec 2009 10:06:58 +0000 (10:06 +0000)
- allow non-root processes to get their own endpoint
- make alloc_contig() call sys_umap() only when requested

etc/drivers.conf
include/minix/type.h
lib/syslib/alloc_util.c
servers/mfs/cache.c
servers/pm/misc.c

index eb0c3e647c884aa46236166ff834a8910973b993..ef62bca246204d6da4ee3d311f60d2f4e096f219 100644 (file)
@@ -290,7 +290,6 @@ driver mfs
                SAFECOPYTO      # 32
                GETINFO
                SETGRANT        # 34
-                UMAP            # 14
                PROFBUF         # 38
                SYSCTL
                ;
index 4dd0edfe97eae7d45692737bcea518eda88b474b..d5a526c3bf9cbd5968e4ee87131fb53ab395d06b 100644 (file)
@@ -162,8 +162,7 @@ struct memory {
 
 #define STATICINIT(v, n) \
        if(!(v)) {      \
-               phys_bytes myph; \
-               if(!((v) = alloc_contig(sizeof(*(v)) * (n), 0, &myph))) { \
+               if(!((v) = alloc_contig(sizeof(*(v)) * (n), 0, NULL))) { \
                        panic(__FILE__, "allocating " #v " failed", n); \
                }       \
        }
index 52d7792e55bc4b3108050256f208c21c328f6237..1fe2e2ec9f949f7af43b5b9832bc8597a7c33971 100644 (file)
@@ -66,8 +66,8 @@ void *alloc_contig(size_t len, int flags, phys_bytes *phys)
                        buf += align - (buf % align);
        }
 
-       /* Get physical address. */
-        if(sys_umap_data_fb(SELF, buf, len, phys) != OK)
+       /* Get physical address, if requested. */
+        if(phys != NULL && sys_umap_data_fb(SELF, buf, len, phys) != OK)
                panic("alloc_contig.c", "sys_umap_data_fb failed", NO_NUM);
 
        return (void *) buf;
index 1936479a703b635db9c5aa315619ade8ae7c9c64..5ccf9aa34122f8ddb84818cca6796b98ae06a846 100644 (file)
@@ -82,10 +82,9 @@ int only_search;             /* if NO_READ, don't read, else act normal */
   if ((bp = front) == NIL_BUF) panic(__FILE__,"all buffers in use", NR_BUFS);
 
   if(bp->b_bytes < fs_block_size) {
-       phys_bytes ph;
        ASSERT(!bp->bp);
        ASSERT(bp->b_bytes == 0);
-       if(!(bp->bp = alloc_contig(fs_block_size, 0, &ph))) {
+       if(!(bp->bp = alloc_contig(fs_block_size, 0, NULL))) {
                printf("MFS: couldn't allocate a new block.\n");
                for(bp = front;
                        bp && bp->b_bytes < fs_block_size; bp = bp->b_next)
index 2d2c3cdf7b54afbdb066eb2d8f1f0497bdaa9a73..27e0aed917b538d38629a65af7a550fe1357cac0 100644 (file)
@@ -314,6 +314,13 @@ PUBLIC int do_getprocnr()
   /* This call should be moved to DS. */
   if (mp->mp_effuid != 0)
   {
+       /* For now, allow non-root processes to request their own endpoint. */
+       if (m_in.pid < 0 && m_in.namelen == 0) {
+               mp->mp_reply.PM_ENDPT = who_e;
+               mp->mp_reply.PM_PENDPT = NONE;
+               return OK;
+       }
+
        printf("PM: unauthorized call of do_getprocnr by proc %d\n",
                mp->mp_endpoint);
        sys_sysctl_stacktrace(mp->mp_endpoint);