source: flash-java-insecure-perms/trunk/fuentes/flash-java-insecure-perms/usr/bin/flash-java-insecure-perms @ 2677

Last change on this file since 2677 was 2677, checked in by mabarracus, 3 years ago

Allow plugins run smoothly educational resources

  • Property svn:executable set to *
File size: 5.3 KB
Line 
1#!/bin/bash
2#0 = autosize
3HEIGHT=0
4WIDTH=0
5LIST_HEIGHT=0
6
7
8ICED=$(which itweb-settings)
9KEYTOOL=$(which keytool)
10IAM=$(id -u)
11MYNAME=$(id -un)
12
13if [ "${IAM}" = "0" ]; then
14    USERS=$(getent passwd |cut -d: -f4|sort -h|uniq|egrep ^[0-9]{4}|xargs -n1 getent passwd|cut -d: -f1)
15    if [ "x$1" = "xinstall" ]; then
16
17        OLDIFS=$IFS;
18        IFS=$'\n'
19        for x in ${USERS} ; do 
20            #str+=( $(printf '%10.10s' $x) $(printf '%30.30s' " ") $(printf '%10.10s' "on"))
21            str+=( $x  " " off )
22        done
23
24        DIALOG=$(whiptail --separate-output --title "Users selection" --checklist "Select users to modify flash/java settings" $HEIGHT $WIDTH $LIST_HEIGHT ${str[@]} 3>&1 1>&2 2>&3)
25        ret=$?
26
27        IFS=$OLDIFS;
28   
29        if [ $ret != 0 ]; then
30        echo Canceled!
31        fi
32    fi
33else
34    USERS=${MYNAME}
35    DIALOG=${MYNAME}
36fi
37
38DONE=0
39if [ "x$1" = "xinstall" ]; then
40
41for x in ${DIALOG}; do
42    DATE=$(date '+%Y%m%d%H%M%S')
43
44    if [ ! -f "/home/$x/.config/unsec_settings_on" ]; then
45        # JAVA
46        if [ ! -z "${ICED}" ]; then
47            sudo su $x bash -c "${ICED} -headless set deployment.security.level ALLOW_UNSIGNED" 
48        fi
49        for cert in $(find /usr/share/flash-java-insecure-perms/ -name '*.cert');do 
50            certname=${cert%%.cert}
51            echo Importing into trusted.certs ${certname}.cert
52            $KEYTOOL -importcert -trustcacerts -storepass "changeit" -keystore /home/$x/.config/icedtea-web/security/trusted.certs -file ${cert} -alias ${certname} -noprompt
53        done
54        #FLASH
55        if [ ! -d "/home/$x/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys" ]; then
56            mkdir -p /home/$x/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys
57        fi
58        if [ ! -d "/home/$x/.macromedia/Flash_Player/#Security/FlashPlayerTrust" ]; then
59            mkdir -p "/home/$x/.macromedia/Flash_Player/#Security/FlashPlayerTrust"
60        fi
61        if [ -f "/home/$x/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/settings.sol" ]; then
62            mv /home/$x/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/settings.sol /home/$x/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/settings-${DATE}.sol
63        fi
64        if [ -f "/home/$x/.macromedia/Flash_Player/#Security/FlashPlayerTrust/recursos.cfg" ]; then
65            mv "/home/$x/.macromedia/Flash_Player/#Security/FlashPlayerTrust/recursos.cfg" "/home/$x/.macromedia/Flash_Player/#Security/FlashPlayerTrust/recursos-${DATE}.cfg"
66        fi
67        cp /usr/share/flash-java-insecure-perms/settings.sol /home/$x/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys
68        cp /usr/share/flash-java-insecure-perms/recursos.cfg "/home/$x/.macromedia/Flash_Player/#Security/FlashPlayerTrust/recursos.cfg"
69        chown -R ${x}:${x} /home/$x/.macromedia
70        touch /home/$x/.config/unsec_settings_on
71        #FIREFOX
72        pkill -u $x --signal 9 firefox
73        for pref in $(find /home/$x/.mozilla -name 'prefs.js'); do
74            sed -i -r 's%.*plugin\.state\.java.*%%' $pref
75            sed -i -r 's%.*plugin\.state\.flash.*%%' $pref
76            sed -i -r 's%.*plugins\.click_to_play.*%%' $pref
77            sed -i -r 's%.*plugins\.hide_infobar_for_outdated_plugin.*%%' $pref
78            # USE ECHO WHEN THERE ISN'T SOME SETTING INTO FILE
79            echo 'user_pref("plugin.state.java",2);' >> $pref
80            echo 'user_pref("plugin.state.flash",2);' >> $pref
81            echo 'user_pref("plugins.click_to_play",false);' >> $pref
82            echo 'user_pref("plugins.hide_infobar_for_outdated_plugin",true);' >> $pref
83        done
84    else
85            echo Already configured!
86    fi
87done
88
89DONE=1
90fi
91
92if [ "x$1" = "xdeinstall" ]; then
93
94    for x in ${USERS}; do
95        if [ -f "/home/$x/.config/unsec_settings_on" ]; then
96            echo Deconfiguring $x!
97            #FLASH
98            file1=$(find /home/$x/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys -maxdepth 1 -name '*.sol'|grep 'settings-'|sort -h|uniq|head -1)
99            if [ ! -z "$file1" ]; then
100                mv $file1 /home/$x/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/settings.sol
101            fi
102            if [ -f "/home/$x/.macromedia/Flash_Player/#Security/FlashPlayerTrust/recursos.cfg" ]; then 
103                rm -f "/home/$x/.macromedia/Flash_Player/#Security/FlashPlayerTrust/recursos.cfg"
104            fi
105            #JAVA
106            if [ ! -z "${ICED}" ]; then
107                sudo su $x bash -c "${ICED} -headless reset deployment.security.level" 
108            fi
109            for cert in $(find /usr/share/flash-java-insecure-perms/ -name '*.cert');do 
110                certname=${cert%%.cert}
111                echo Deleting ${certname}.cert from trusted.certs
112                $KEYTOOL -delete -storepass "changeit" -keystore /home/$x/.config/icedtea-web/security/trusted.certs -alias ${certname}
113            done
114            rm /home/$x/.config/unsec_settings_on
115            pkill -u $x --signal 9 firefox
116            for pref in $(find /home/$x/.mozilla -name 'prefs.js'); do
117                sed -i -r 's%.*plugin\.state\.java.*%user_pref("plugin.state.java",1);%' $pref
118                sed -i -r 's%.*plugin\.state\.flash.*%user_pref("plugin.state.flash",1);%' $pref
119                sed -i -r 's%.*plugins\.click_to_play.*%user_pref("plugins.click_to_play",true);%' $pref
120                sed -i -r 's%.*plugins\.hide_infobar_for_outdated_plugin.*%user_pref("plugins.hide_infobar_for_outdated_plugin",false);%' $pref
121
122                #echo 'user_pref("plugin.state.java",1)' >> $pref
123                #echo 'user_pref("plugin.state.flash",1)' >> $pref
124                #echo 'user_pref("plugins.click_to_play",true)' >> $pref
125                #echo 'user_pref("plugins.hide_infobar_for_outdated_plugin",false)' >> $pref
126            done
127        fi
128    done
129DONE=1
130fi
131
132if [ ${DONE} -eq 0 ]; then
133    echo "$(basename $0) help"
134    echo "$(basename $0) [ install | deinstall ]"
135    echo "Changes permission to allow some educational resources with java/flash"
136fi
Note: See TracBrowser for help on using the repository browser.