Changeset 344 for trunk


Ignore:
Timestamp:
Mar 30, 2008, 5:09:46 AM (17 years ago)
Author:
broder
Message:

New sipb-xen-console. Now with more magic - and more working

This package installed onto a clean Debian system should do all of the setup
for a console server except for copying the ssh private keys, granting access
to the Postgres database, and Kerberos keytabs

Location:
trunk/packages/sipb-xen-console
Files:
5 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-console/debian/changelog

    r335 r344  
     1sipb-xen-console (2) unstable; urgency=low
     2
     3  * Actually functional release.
     4
     5 -- SIPB Xen Project <sipb-xen@mit.edu>  Sun, 30 Mar 2008 05:07:43 -0400
     6
    17sipb-xen-console (1) unstable; urgency=low
    28
  • trunk/packages/sipb-xen-console/debian/control.in

    r335 r344  
    1010Provides: ${diverted-files}
    1111Conflicts: ${diverted-files}
    12 Depends: ${shlibs:Depends}, ${misc:Depends}, fuse-utils, libnss-pgsql1, openssh-client, openssh-server, python-fuse, sipb-xen-database-common
     12Depends: ${shlibs:Depends}, ${misc:Depends}, daemon, fuse-utils, libnss-pgsql1, nscd, openssh-client, openssh-server, python-fuse, sipb-xen-database-common
    1313Description: SIPB Xen serial console server
    1414 This package  should be installed on sipb-xen-console
  • trunk/packages/sipb-xen-console/debian/rules

    r335 r344  
    44DEB_DIVERT_EXTENSION = .sipb-xen
    55DEB_DIVERT_FILES_sipb-xen-console += \
    6         /etc/nsswitch.conf
     6        /etc/nscd.conf \
     7        /etc/nsswitch.conf \
     8        /etc/pam.d/ssh \
    79        /etc/ssh/ssh_config
    810
  • trunk/packages/sipb-xen-console/debian/sipb-xen-console.init

    r335 r344  
    6464        # Many daemons don't delete their pidfiles when they exit.
    6565        rm -f $PIDFILE
     66        umount "$DAEMON_ARGS"
    6667        return "$RETVAL"
    6768}
  • trunk/packages/sipb-xen-console/files/etc/nss-pgsql.conf

    r335 r344  
    66database        = sipb_xen
    77login           = sipb-xen
    8 #passwd         = foo
    9 #passwdtable    = machines
    10 #grouptable     = machines
    11 # you can use anything postgres accepts as table expression
    12 #groupmembertable = accounts JOIN usergroups ON accounts.uid=usergroups.uid JOIN groups ON usergroups.gid=groups.gid
    138
    14 querypasswd = SELECT name, 'moo', 1000 as uid, 1000, '', '/vmhome/'|| name, '/usr/local/bin/sipb-xen-consolesh' FROM machines
    15 querygroup = SELECT name, NULL, 1000 as gid FROM machines
    16 querymembers = SELECT name FROM machines WHERE 1000 = %d
    17 queryids = SELECT 1000 AS gid FROM machines LIMIT 0;
     9querypasswd = SELECT name, NULL, machine_id + 1000 as uid, machine_id + 1000 as gid, '', '/consolefs/'|| name, '/usr/bin/sipb-xen-consolesh' FROM machines
     10querygroup = SELECT name, NULL, machine_id + 1000 as gid FROM machines
     11querymembers = SELECT name FROM machines WHERE 1000 + machine_id = %d
     12queryids = SELECT 1000 + machine_id AS gid FROM machines LIMIT 0
    1813
    1914passwd_name = name
    20 passwd_uid = uid
     15passwd_uid = 1000 + machine_id
    2116
    2217group_name = name
    23 group_gid = gid
     18group_gid = 1000 + machine_id
  • trunk/packages/sipb-xen-console/files/etc/nsswitch.conf.sipb-xen

    r335 r344  
    66
    77passwd:         compat pgsql
    8 group:          compat
     8group:          compat pgsql
    99shadow:         compat
    1010
  • trunk/packages/sipb-xen-console/files/etc/ssh/ssh_config.sipb-xen

    r335 r344  
    1818
    1919Host *
    20    SetEnv VM_NAME
     20   SendEnv VM_NAME
    2121#   ForwardAgent no
    2222#   ForwardX11 no
  • trunk/packages/sipb-xen-console/files/usr/bin/sipb-xen-consolefs

    r335 r344  
    1111                           # - note: these must be returned as negatives
    1212
     13import sipb_xen_database
     14
    1315fuse.fuse_python_api = (0, 2)
    1416
    15 machines = ['moo17', 'remus']
    1617realpath = "/home/machines/"
    17 uid = 1000
    1818
    1919def dirFromList(list):
     
    4848                self.st_dev = 0
    4949                self.st_nlink = 0
    50                 self.st_uid = uid
     50                self.st_uid = 0
    5151                self.st_gid = 0
    5252                self.st_size = 0
     
    6464        def __init__(self, *args, **kw):
    6565                Fuse.__init__(self, *args, **kw)
     66                self.lasttime = time()
     67                self.allow_other = 1
    6668                print 'Init complete.'
    6769       
    6870        def mirrorPath(self, path):
    6971                return realpath + "/".join(getParts(path)[1:])
     72       
     73        def getMachines(self):
     74                if time() - self.lasttime > 15:
     75                        self.lasttime = time()
     76                        sipb_xen_database.clear_cache()
     77                return [machine.name for machine in sipb_xen_database.Machine.select()]
     78       
     79        def getUid(self, machine_name):
     80                return sipb_xen_database.Machine.get_by(name=machine_name).machine_id + 1000
     81       
     82        def getK5login(self, machine_name):
     83                machine = sipb_xen_database.Machine.get_by(name=machine_name)
     84                users = [acl.user for acl in machine.acl]
     85                return "\n".join(map(self.userToPrinc, users) + [''])
     86       
     87        def userToPrinc(self, user):
     88                if '@' in user:
     89                        (princ, realm) = user.split('@')
     90                else:
     91                        princ = user
     92                        realm = "ATHENA.MIT.EDU"
     93               
     94                return princ.replace('.', '/') + realm
    7095       
    7196        def getattr(self, path):
     
    94119                        st.st_nlink = 2
    95120                elif depth == 1:
    96                         if parts[-1] in machines:
     121                        if parts[-1] in self.getMachines():
    97122                                st.st_mode = stat.S_IFDIR | 0755
    98123                                st.st_nlink = 2
     124                                st.st_uid = st.st_gid = self.getUid(parts[0])
    99125                        else:
    100126                                return -errno.ENOENT
     
    102128                        st.st_mode = stat.S_IFREG | 0444
    103129                        st.st_nlink = 1
    104                         st.st_size = 17
     130                        st.st_size = len(self.getK5login(parts[0]))
     131                        st.st_uid = st.st_gid = self.getUid(parts[0])
    105132                else:
    106                         st = os.lstat(self.mirrorPath(path))
     133                        stats = list(os.lstat(self.mirrorPath(path)))
     134                        stats[4:6] = [self.getUid(parts[0])] * 2
     135                        return tuple(stats)
    107136                return st.toTuple()
    108137       
    109138        def readdir(self, path, offset):
    110139                print '*** readdir', path, offset
     140                for (value, zero) in self.getdir(path):
     141                        yield fuse.Direntry(value)
     142       
     143        def getdir(self, path):
     144                print '*** getdir', path
    111145                if path == '/':
    112                         for r in  ['.', '..']+machines:
    113                                 yield fuse.Direntry(r)
     146                        contents = ['.', '..']+self.getMachines()
    114147                elif getDepth(path) == 1:
    115                         for r in set(os.listdir(self.mirrorPath(path)) + ['.k5login']):
    116                                 yield fuse.Direntry(r)
     148                        contents = set(os.listdir(self.mirrorPath(path)) + ['.k5login', '.', '..'])
    117149                else:
    118                         for r in os.listdir(self.mirrorPath(path)):
    119                                 yield fuse.Direntry(r)
     150                        contents = os.listdir(self.mirrorPath(path)) + ['.', '..']
     151                return [(i, 0) for i in contents]
    120152       
    121153        def read ( self, path, length, offset ):
    122154                print '*** read', path, length, offset
    123155               
     156                parts = getParts(path)
     157               
    124158                if getDepth(path) < 2:
    125159                        return -errno.ENOENT
    126                 elif getParts(path)[1:] == ['.k5login']:
    127                         pass
     160                elif parts[1:] == ['.k5login']:
     161                        if parts[0] not in self.getMachines():
     162                                return -errno.ENOENT
     163                        else:
     164                                return self.getK5login(parts[0])[offset:length + offset]
    128165                else:
    129166                        fname = self.mirrorPath(path)
     
    136173
    137174if __name__ == '__main__':
     175        sipb_xen_database.connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')
    138176        usage="""
    139177ConsoleFS [mount_path]
Note: See TracChangeset for help on using the changeset viewer.