mkogg.py: Fix 'self.get_mp4_metadata(self, source)'
[blog.git] / posts / Kerberos / kinit-mpd.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2011 W. Trevor King <wking@drexel.edu>
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this program.  If not, see
17 # <http://www.gnu.org/licenses/>.
18
19 # usage: kinit-mpd.sh
20 #
21 # Uses root permissions to assume `nobody` credentials from a central
22 # keytab, and then transfers ownership of the resulting ticket to the
23 # `mpd` user.
24
25 ROOT_UID=$(id --user root)
26 MPD_UID=$(id --user mpd)
27 NOBODY_KEYTAB=/etc/krb5.nobody.keytab
28 NOBODY_USER=nobody
29
30 sudo kinit -k -t "${NOBODY_KEYTAB}" "${NOBODY_USER}"
31 sudo mv "/tmp/krb5cc_${ROOT_UID}" "/tmp/krb5cc_${MPD_UID}"
32 sudo chown mpd.audio "/tmp/krb5cc_${MPD_UID}"