[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright ACE-desktop/ACE ACE-desktop/system.an...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright ACE-desktop/ACE ACE-desktop/system.an... |
Date: |
Thu, 01 Mar 2007 06:13:41 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/03/01 06:13:41
Modified files:
ACE-desktop : ACE system.antiright
gshterm : script.c
libantiright : string.c
Log message:
Reimplemented antiright_beautify_label(). Reimplemented ACE's
Deskbar, Settings utility, File Manager, and manual page browser
to use variable command construction rather than temporary files.
This should improve security, speed, and ease of development.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/ACE-desktop/ACE?cvsroot=antiright&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/antiright/ACE-desktop/system.antiright?cvsroot=antiright&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/script.c?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/string.c?cvsroot=antiright&r1=1.5&r2=1.6
Patches:
Index: ACE-desktop/ACE
===================================================================
RCS file: /sources/antiright/antiright/ACE-desktop/ACE,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- ACE-desktop/ACE 28 Feb 2007 06:55:27 -0000 1.18
+++ ACE-desktop/ACE 1 Mar 2007 06:13:41 -0000 1.19
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -m
# AntiRight (c) 2002-2007 Jeffrey Bedard address@hidden
@@ -16,11 +16,13 @@
# AntiRight; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+# /bin/sh should have job control enabled. (-m)
+
icon=$PREFIX/share/ACE-desktop/icons
DEBUG=0
if [ "$DEBUG" = "1" ]; then
- set -vx
+ #set -vx
Debug()
{
COUNTER=$(($COUNTER+1))
@@ -149,36 +151,44 @@
$ARSHELL -or 5 -al "$(ls -l $1)" -ar\
-al 'Drag a mode to the appropriate chmod'\
'chmod u' 'chmod g' 'chmod o' -ar -al add: '+r' '+w' '+x'\
- -ar -al subtract: '-r' '-w' '-x'
+ -ar -al subtract: 'chmod -r' '-w' '-x'
Check_AR_IN_FM
}
-
+FM_Text_Editor()
+{
+ ACE Text_Editor $@ &
+ ACE -A File_Manager &
+}
File_Manager()
{
- cd $1 2> /dev/null
- local TMP=$(Get_Temp File_Manager)
- Prepare_Temp_Script $TMP
- echo "export AR_IN_FM=1" >> $TMP
- echo "exec $ARSHELL -os -og 750x500 -oe -al $(pwd)\\" >> $TMP
+ if [ "$1" != "" ]; then
+ cd $1
+ fi
+ export AR_IN_FM=1
+ local CMD="exec $ARSHELL -or 16 -og 750x500 -oe -al $(pwd)"
local FM="ACE -A File_Manager"
- echo " 'ACE -A Delete & # ACE_-A_Delete'\\" >> $TMP
- echo " 'ACE Text_Editor & # ACE_Text_Editor'\\" >> $TMP
- echo " 'ACE -A Move & # ACE_-A_Move'\\" >> $TMP
- echo " 'ACE -A Copy & # ACE_-A_Copy'\\" >> $TMP
- echo " 'ACE -A Command & # ACE_-A_Command'\\" >> $TMP
- echo " 'ACE -A Modes & # ACE_-A_Modes'\\" >> $TMP
- echo " 'ACE -A File_Manager # Refresh'\\" >> $TMP
- for file in *; do
- echo " '""ACE -A ARO $file & # $file""'\\" >> $TMP
+ CMD="$CMD 'exit # CLOSE'"
+ CMD="$CMD \"cd .. ; $FM & # UP\""
+
+ CMD="$CMD 'ACE -A Delete & # ACE_-A_Delete'"
+ CMD="$CMD 'ACE Text_Editor & # address@hidden@Editor'"
+ CMD="$CMD 'ACE -A Move & # ACE_-A_Move'"
+ CMD="$CMD 'ACE -A Copy & # ACE_-A_Copy'"
+ CMD="$CMD 'ACE -A Command & # ACE_-A_Command'"
+ CMD="$CMD 'ACE -A Modes & # ACE_-A_Modes'"
+ CMD="$CMD 'ACE -A File_Manager & # Refresh'"
+ CMD="$CMD -al '--------'"
+ local FILE
+ for FILE in *; do
+ CMD="$CMD \"ACE -A ARO $FILE & # $FILE\""
done
- echo " 'exit # CLOSE'\\" >> $TMP
- echo " '""cd .. ; $FM & \# UP""'" >> $TMP
+ CMD="$CMD 'exit # CLOSE'"
+ CMD="$CMD \"cd .. ; $FM & # UP\""
if [ "$DEBUG" = "1" ]; then
- cat $TMP
+ echo $CMD
fi
- cat $TMP | grep -n --color=always '.*'
- $TMP
- rm -f $TMP
+ #echo $CMD
+ exec sh -c "$CMD"
}
Clock()
{
@@ -186,19 +196,15 @@
}
Console()
{
- local TMP=$(Get_Temp Console)
- Prepare_Temp_Script $TMP
-
- echo "$ARSHELL -os -og 750x500+0-0 -ou 5000\\" >> $TMP
+ local CMD="$ARSHELL -os -og 750x500+0-0 -ou 5000 "
for ITEM in "$@"; do
- echo " -al $ITEM -aul \"tail -n 3 $ITEM\" \\" >> $TMP
+ CMD="$CMD -al $ITEM -aul \"tail -n 3 $ITEM\" "
done
- echo " -aul date" >> $TMP
-
- $TMP
- rm -f $TMP
+ CMD="$CMD -aul date"
+ echo "$CMD"
+ exec sh -c "$CMD"
}
swap_load()
{
@@ -218,7 +224,7 @@
Old_Deskbar()
{
- $ARSHELL -og $(ACE Deskbar_X)$(ACE Deskbar_Y)\
+ exec $ARSHELL -og $(ACE Deskbar_X)$(ACE Deskbar_Y)\
-or 1\
-aul "uptime | tr -d '\n'"\
'ACE Lock'\
@@ -247,45 +253,37 @@
local ACE_STRING=" -aI ACE $icon/ACE.png"
local UPDATER=$(ACE deskbar_updater)
- local TMP=$(Get_Temp Deskbar)
- # Ensure removal on termination.
- # Set correct permissions and shell.
- Prepare_Temp_Script $TMP
-
- echo "exec $ARSHELL -of -on $OPTIONS \\" >> $TMP
- echo " -og +$(ACE Deskbar_X)+$(ACE Deskbar_Y)\\" >> $TMP
+ local CMD="exec $ARSHELL -of -on $OPTIONS"
+ CMD="$CMD -og +$(ACE Deskbar_X)+$(ACE Deskbar_Y)"
if [ "$UPDATER" = "TRUE" ]; then
- echo " $ACE_STRING\\" >> $TMP
+ CMD="$CMD $ACE_STRING"
fi
if [ "$STYLE" = "1" ]; then
- echo " -at env\\" >> $TMP
+ CMD="$CMD -at env"
fi
for item in $(ACE Panel_Items); do
- echo ' -aI '"'"ACE $item"'" $icon/$item.png "\\"\
- >> $TMP
+ CMD="$CMD -aI \"ACE $item\" $icon/$item.png"
done
if [ "$UPDATER" = "TRUE" ]; then
- echo " -aul 'ACE -A taskbar_update'" >> $TMP
+ CMD="$CMD -aul 'ACE -A taskbar_update'"
else
- echo " $ACE_STRING" >> $TMP
+ CMD="$CMD $ACE_STRING"
fi
-
- $TMP
- rm -f $TMP
-
+ #echo "$CMD"
+ exec sh -c "$CMD"
fi
}
ARO()
{
# TMP=Get_Temp ARO
# TMP=Prepare_Temp $TMP
- TMP=/tmp/ARO.$$
- echo $@
+# echo $@
if [ $# -gt 0 ]; then
+ TMP=/tmp/ARO.$$
file $1 > $TMP
if grep script $TMP; then
$@ &
@@ -326,13 +324,13 @@
# Execute the file.
$@ &
fi
+ rm -f $TMP
else
$ARSHELL -de "No arguments were specified" &
fi
if [ "$AR_IN_FM" = "1" ]; then
File_Manager
fi
- rm -f $TMP
}
Read_Man_Page()
{
@@ -340,40 +338,33 @@
}
Man_Browse_Section()
{
- local tf=/tmp/antiright_mbs.$$
- touch $tf
- trap "rm -f $tf" EXIT
- chmod og-rwx $tf
- chmod u+x $tf
- echo '#!/bin/sh' >> $tf
- echo "$ARSHELL -os -og 500x450 -or 42\\" >> $tf
+ local CMD="exec $ARSHELL -os -og 500x450 -or 42"
manual_root=$(ACE Manual_Root)
cd $manual_root/man$1
- echo "'Manual Section "$1"' \\" >> $tf
+ CMD="$CMD \"Manual Section $1\"" >> $tf
for file in $(ls | cut -d. -f1); do
- echo " 'ACE -A Read_Man_Page "$1 $file"' \\" >> $tf
+ CMD="$CMD \"ACE -A Read_Man_Page $1 $file\""
done
- echo " 'ACE -A Man_Browse_Section $1 # Back'" >> $tf
+ CMD="$CMD \"ACE -A Man_Browse_Section $1 # Back\""
if [ "DEBUG" = "1"]; then
- cat $tf > /tmp/tf.out
+ echo $CMD
fi
-
- $tf
- rm -f $tf
+ exec sh -c "$CMD"
}
Manual_Browser()
{
mbs=Man_Browse_Section
- $ARSHELL -or 3 -al "Manual section:" -al ' ' -al ' '\
+ exec $ARSHELL -or 3 -al "Manual section:" -al ' ' -al ' '\
"ACE -A $mbs 1" "ACE -A $mbs 2"\
"ACE -A $mbs 3" "ACE -A $mbs 4" "ACE -A $mbs 5"\
- "ACE -A $mbs 6" "ACE -A $mbs 7" "ACE -A $mbs 8" "ACE -A $mbs 9"
+ "ACE -A $mbs 6" "ACE -A $mbs 7" "ACE -A $mbs 8"\
+ "ACE -A $mbs 9"
}
ACE_Panel()
{
- $ARSHELL -or 5 \
+ exec $ARSHELL -or 5 \
'ACE IRC' \
'ACE CD_Player' \
'ACE File_Manager' \
@@ -402,11 +393,11 @@
}
Calendar()
{
- $ARSHELL -al "$(cal)"
+ exec $ARSHELL -al "$(cal)"
}
ARI()
{
- $ARSHELL 'make install; $ARSHELL -r 1 Done; echo Install' > /dev/null &
+ $ARSHELL 'make install; $ARSHELL -r 1 Done; echo Install' >& /dev/null &
}
Diff()
{
@@ -435,8 +426,11 @@
Settings_Node()
{
new_value=$($ARSHELL -og 256x154\
+ -al 'Current command:'\
-al "$(ACE -r $1)"\
- -oe -at "echo")
+ -al 'Enter a new command:'\
+ -oe -at "echo"\
+ '# Close')
# echo new value is $new_value
if [ "$new_value" != "" ]; then
set_value $1 "$new_value"
@@ -446,14 +440,11 @@
{
# Ensure the existance of a configuration file.
ACE_Check_Configuration_File
- local TMP=${TMPDIR:-/tmp}/ACE.$$
- echo "$ARSHELL -or 11"\\ > $TMP
- for title in $(ACE_record_titles)
- do
- echo " \"ACE -A Settings_Node $title\""\\ >> $TMP
+ local CMD="exec $ARSHELL -or 10"
+ for title in $(ACE_record_titles); do
+ CMD="$CMD \"ACE -A Settings_Node $title\""
done
- sh $TMP
- trap "rm $TMP* 2>/dev/null" 0
+ exec sh -c "$CMD"
}
Load_Meter()
{
@@ -473,7 +464,7 @@
File_System_Panel()
{
- $ARSHELL -or 2 \
+ exec $ARSHELL -or 2 \
'ACE -A Mount_File_System'\
'ACE -A Unmount_File_System'\
'ACE See_Free_Space'\
@@ -483,7 +474,7 @@
Network_Panel()
{
- $ARSHELL -or 3 \
+ exec $ARSHELL -or 3 \
'ACE -A Open_Display' 'ACE Open_URL'\
'ACE -A ACE_peer_operation ftp'\
'ACE -A ACE_peer_operation telnet'\
@@ -499,7 +490,7 @@
}
Monitoring_Panel()
{
- $ARSHELL -or 5 \
+ exec $ARSHELL -or 5 \
"$ARSHELL -aul 'ps xau' & # Processes"\
"$ARSHELL -aul who & # Users"\
"$ARSHELL -aul df & # Disks"\
@@ -510,7 +501,7 @@
}
Administration_Panel()
{
- $ARSHELL -or 3 \
+ exec $ARSHELL -or 3 \
'ACE -A Secure_Permissions'\
'ACE Root_Shell'\
'ACE -A Monitoring_Panel'\
@@ -521,7 +512,7 @@
if [ "$(which sar)" != "" ]; then
$ARSEHLL -aul sar
else
- ACE -A Message 'SAR must be installed.'
+ Message 'SAR must be installed.'
fi
}
Secure_Permissions()
@@ -542,24 +533,6 @@
{
$ARSHELL -aul 'ps u'
}
-rgb_background()
-{
- if [ -f $HOME/.antiright_background ]; then
- cat $HOME/.antiright_background
- else
- echo black
- fi
-}
-Background_Editor()
-{
- color="$($ARSHELL -l Color: -t echo)"
- if [ "$color" != "" ]; then
- echo $HOME
- echo $color > $HOME/.antiright_background
- set_value background 'ACE -A rgb_background'
- restart_desktop
- fi
-}
Mount_File_System()
{
ACE -L 'File System' mount
@@ -572,10 +545,6 @@
{
ACE Terminal -e less /etc/fstab &
}
-Manual_Page()
-{
- ACE Terminal -e man $1
-}
ACE_peer_operation()
{
ACE -L "$(echo -n $1 | tr [a-z] [A-Z]) Peer" ACE Terminal -e $1
@@ -625,7 +594,7 @@
}
Publishing_Panel()
{
- $ARSHELL -or 4\
+ exec $ARSHELL -or 4\
'ACE -A Preview_roff'\
'ACE -A Print_roff'\
'ACE -A Save_PDF'\
Index: ACE-desktop/system.antiright
===================================================================
RCS file: /sources/antiright/antiright/ACE-desktop/system.antiright,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- ACE-desktop/system.antiright 18 Feb 2007 22:43:25 -0000 1.3
+++ ACE-desktop/system.antiright 1 Mar 2007 06:13:41 -0000 1.4
@@ -34,7 +34,6 @@
# customized.
# Applications
-ACE: ACE
Browser: exec firefox
Mail:ACE Terminal -e mail
Image_Editor:exec gimp
@@ -43,7 +42,7 @@
Calculator: exec gcalctool
Text_Editor: exec gvim
CD_Player: ACE Terminal cdplay
-Cal: ACE -A Calendar
+Calendar: ACE -A Calendar
System_Monitor: nice ACE Terminal -e top
Print:lpr
PPP_On:wvdial
@@ -64,7 +63,6 @@
background: echo grey30
foreground: echo black
# Customizations
-Terminal:exec mrxvt
IRC:ACE Terminal -e irc
PPP_Off:pkill pppd
mp3_dir:~/archive/music
@@ -72,8 +70,6 @@
Lock_Display:exec xlock -mode blank
deskbar_style: echo 1
deskbar_updater: echo TRUE
-IRC:IRC: [ACE Terminal -e irc] xchat
-IRC: [ACE Terminal -e irc] xchat
Browser:exec firefox2
Sticky_Note: ACE -A Sticky_Note
Panel_Items: echo Lock_Display Screen Terminal File_Manager System_Monitor
Browser File_Sharing Text_Editor Word_Processor Image_Editor Calculator
Sticky_Note
Index: gshterm/script.c
===================================================================
RCS file: /sources/antiright/antiright/gshterm/script.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gshterm/script.c 28 Feb 2007 03:53:51 -0000 1.6
+++ gshterm/script.c 1 Mar 2007 06:13:41 -0000 1.7
@@ -24,41 +24,42 @@
#include <sys/types.h>
#include <sys/stat.h>
+/* Returned value must be freed. */
char *
gshterm_command_script(char *command)
{
gchar *script_name;
FILE *script;
- pid_t pid;
+ gint fd;
#ifdef DEBUG
ARBUG("gshterm_command_script()");
#endif /* DEBUG */
- /* This is a workaround for vte's fscking up of option arrays. */
+ ARPASSERT(command);
- pid = getpid();
- ar_asprintf(&script_name, "/tmp/gshterm.%d", (int) pid);
- script = fopen(script_name, "w");
- ARIFNP(script)
- ARERR("script file could not be opened");
+ /* This is a workaround for vte's fscking up of option arrays. */
- fflush(script);
+ fd = g_file_open_tmp("gshterm.XXXXXX", &script_name, NULL);
+ ARASSERT(fd != -1);
/*
* Do this immediately after opening in order to reduce the
* possiblity of script modification exploit.
*/
-
- if (chmod(script_name, S_IXUSR | S_IRUSR | S_IWUSR) != 0)
+ if (fchmod(fd, S_IXUSR | S_IRUSR | S_IWUSR) != 0)
ARERR("script file does not exist");
- fprintf(script, "#!/bin/sh\n");
- fprintf(script, "%s\n", command);
- g_free(command);
- fflush(script);
- fclose(script);
+ ARIFNP((script=fdopen(fd, "w")))
+ ARERR("script file could not be opened");
+ //fflush(script);
+ if(fsync(fd) == EOF)
+ ARERR("cannot write script file");
+
+ fprintf(script, "#!/bin/sh\n%s\n", command);
+ g_free(command);
+ fclose(script); /* Close and flush buffers. */
#ifdef DEBUG
sysprintf("cat %s", script_name);
Index: libantiright/string.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/string.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libantiright/string.c 28 Feb 2007 03:53:51 -0000 1.5
+++ libantiright/string.c 1 Mar 2007 06:13:41 -0000 1.6
@@ -32,45 +32,34 @@
return_value = g_vasprintf(string, format, list);
va_end(list);
+ ARASSERT(return_value != -1);
+
return return_value;
}
/* Free the returned value! */
-/* (This is rather scary) */
char *
-antiright_beautified_label(char *current_argument_string)
+antiright_beautified_label(char *text)
{
- char *label_string = xmalloc(strlen(current_argument_string));
- int parse_counter;
- int label_counter;
+ gint i, length;
+ gchar *formatted;
- for (parse_counter = strlen(current_argument_string);
- ((current_argument_string[parse_counter]) != ' ' &&
(parse_counter > 0));
- parse_counter--);
- for (label_counter = 0;
- current_argument_string[parse_counter] != '\0';
- parse_counter++)
- {
- if (current_argument_string[parse_counter] == ' ')
- {
- parse_counter++; /* This gets rid of an
- * extra leading space. */
- }
- if (current_argument_string[parse_counter] != '_')
+ length=strlen(text);
+ for(i = 0; (i < length) && (*(text+length-i) != ' '); i++);
+ text+=length-i;
+ length=ar_asprintf(&formatted, "%s", text);
+ for (i = 0; i < length; i++)
{
- label_string[label_counter] =
- current_argument_string[parse_counter];
+ if (formatted[i] == '_')
+ formatted[i]=' ';
+ /* This substitution is needed for constructing ACE
+ * commands on drag & drop. */
+ if (formatted[i] == '@')
+ formatted[i]='_';
}
- else
- {
- label_string[label_counter] = ' ';
- }
- label_counter++;
- }
-
/* Ensure that the string is null-terminated. */
- label_string[label_counter] = '\0';
+ formatted[i]='\0';
- return (label_string);
+ return (formatted);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright ACE-desktop/ACE ACE-desktop/system.an...,
Jeffrey Bedard <=