Puppy In-House Development

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#281 Post by technosaurus »

Ibidem wrote:On a completely unrelated note, I finally put my "wpanet" service on github (under CC0).
http://github.com/idunham/wpanet
It just starts wpa_supplicant and wpa_cli, and uses the second to start dhcp at the right time.
I find that it works well for connecting to wireless (including how it handles flakey connections).

But it does not have any tools for configuration, especially for setting up the first wpa_supplicant.conf. If someone wants to write one, I'd appreciate it...as long as they don't add too much bloat.
As far as dependencies go:
not python, not perl; some versions I can think of include: Tcl/Tk, bash/ksh with select, sh with dialog/xdialog/?whiptail, or sh with gtkdialog[123].
A C frontend is also acceptable, if it doesn't drag in too many libraries.
The minimum functionality that would be needed is:
-Create new config file (with ctrl_interface=/var/run/wpa_supplicant )
-View networks (wpa_cli scan_results)
-Add network (from the list of scan results or otherwise; support open/wep/wpa)
-disconnect/reassociate
All of these except 1. can be done from wpa_cli.
Feel free to totally disagree with me, but I always felt like configuration guis, especially those associated with internet connection would be best suited to a web interface (axhttpd or busybox httpd + shell cgi for example) This would allow us to modify the "no internet access" webpage to redirect to localhost/cgi-bin/config-network.cgi ... I wrote a bunch of helpers for creating html forms that can be used with cgi scripts in my old bashbox thread that could be used for this.... and even some menus, draggable icons and "windows" that were intended for a web desktop (see web programming thread) ... but the config pages would just be forms that will work with any forms capable browser including links (using css to make them look "pretty" in supporting browsers) for security purposes use .htaccess to allow only localhost connections and chmod extra config files so only the httpd process has access (for instance a file with the WPA password(s) for auto config could be placed there by root or the cgi script itself) I realize it is yet another process running in the background, but it is small and has many other uses.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#282 Post by Ibidem »

technosaurus wrote:Although the values are short, Linux syscalls always take and return longs whether it be a pointer, integer type, or string ... the conversion is handled by the libc (I have a working syscall implementation if you want to see how it works)

The flag -r should not be passed without -l, so the (FLAG_l | FLAG_r) ... unless I add another option for just value such that -l always sets the MSB and -r always sets the LSB if passed individually and the -v (or whatever) sets the entire value from 0 to max unsigned long which could work for setting l and r simultaneously or to workaround strange behaviors one might encounter - currently this is how -l without a -r is supposed to work.
I have an odd builtin microphone that needs to have one channel set to ~mute for it to work, so setting -r without -l is meaningful...
(Yes, treating this as an implied -l 0 is OK.)
... need to see if
a) toybox already has a way to dissallow one flag without the other
b) use the existing value to allow changing only -r or -l like:???
- -l: level = (level & 0xFF) | (TT.level<<8)
-r: level = (level & 0xFF00) | (TT.right)
-v: level = TT.value
Regarding (a), there are ways to make one flag imply, unset, or forbid anther. See code.html, section [groups].

Speaking of that, l#r# should probably be "l#<0>100r#<0>100", since (as far as I know) a channel's volume must be no more than 100 nor less than 0.

Regarding a CGI interface for wpanet: I have no objection to a CGI interface, so long as it is not intended to exclude all others. I'm inclined to think that one text mode UI, at least one graphical UI, and a CGI interface would be nice ;)
But my experience with anything http-related consists of getting http://myweb.csuchico.edu/~idunham/ set up, so I certainly don't want to write the CGI part.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#283 Post by technosaurus »

Ibidem wrote:Speaking of that, l#r# should probably be "l#<0>100r#<0>100", since (as far as I know) a channel's volume must be no more than 100 nor less than 0.
You would hope so, but who knows what vendor implemented a "This one goes to 11." mode. As it is -l should be limited to 65536 when no -r flag is present and -r should be limited to 256 (and -l when -r is present) ... I'm thinking:
v#<0>65536 ... is there a better/standard letter to use than v?, possibly any argument without a flag?
r#<0>256
l#<0>256

If you can write shell scripts, cgi is easy - all you have to do is parse the $QUERY_STRING environment variable in ?var=value&var2=value2 format as you would normally use $1, $2. That can be as simple as:

Code: Select all

IFS="?&"
for PAIR in $QUERY_STRING;do
case $PAIR in
  var=*)VAR=${PAIR#*=} #do stuff with $VAR
  ;;
  var2=*): handle var2;;
  *): handle error;;
esac
#reset IFS
The rest is just html and http headers - where only Content-length: changes
For Content-length: field I keep the whole page in a variable HTML and use:
Content-length: ${#HTML}
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#284 Post by technosaurus »

Ibidem wrote:I have an odd builtin microphone that needs to have one channel set to ~mute for it to work, so setting -r without -l is meaningful...
(Yes, treating this as an implied -l 0 is OK.)
-l 100 without -r sets the _level_ (not left) to 100 which is the same as -l 0 -r 100 (if -r is not given, this level will be the right channel if there are 2 channels and the left will be 0, but -l is intended to be used on mono/single level systems) ... to set left to 100 and right to zero you would need -l 100 -r 0 ... not sure the best way to convey this in --help but -l alone is overall level for the whole device, and you should use -l in combination with -r with explicitly set values for setting individual channels ... perhaps allow #<-1>100 so -1 means keep existing level for that channel?
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#285 Post by greengeek »

Ibidem wrote:But it does not have any tools for configuration, especially for setting up the first wpa_supplicant.conf. If someone wants to write one, I'd appreciate it...as long as they don't add too much bloat. .
Is that one of the configuration functions provided by rcrsn51's peasywifi? It seems a simple front end that worked well for me.

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#286 Post by Ibidem »

greengeek wrote:
Ibidem wrote:But it does not have any tools for configuration, especially for setting up the first wpa_supplicant.conf. If someone wants to write one, I'd appreciate it...as long as they don't add too much bloat. .
Is that one of the configuration functions provided by rcrsn51's peasywifi? It seems a simple front end that worked well for me.
Yes it is, but...to go with wpanet I'm looking for a tool that isn't going to try killing the wpa_supplicant process wpanet starts, starting wpa_supplicant itself without wpa_cli, using both gtkdialog3 and xdialog at the same time, while hard-coding the usage of a specific dhcp client that doesn't come with Busybox, and so on.
I'm sure it works for most purposes, but the backend is exactly what wpanet is about avoiding, the frontend is inextricably combined with the backend, and I figure that one *dialog is enough for what I want to do but I'd like to have a good range of systems the config tool can run on.
Support for gtk+1.2-only systems (gtkdialog1/xdialog) and plain textmode (select/dialog) is important.
[Edit]I wrote wpanet after I saw a dhcp client panic my kernel because it started at the wrong time while the wireless was not connected (kernel 2.6.32, Ubuntu 10.04, madwifi-hal-0.10.5.6). So I'm not using or recommending something that starts wpa_supplicant but doesn't use a wpa_cli action script to control the dhcp client.
[/Edit]

I was thinking of something that would use xdialog or dialog based on runtime detection of what's installed and working, that would _only_ deal with configuration, and that could coexist with any wpa_supplicant service that supports wpa_cli.
I have a skeleton of a prototype already; it uses dialog so making it use xdialog would be easy.

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

wpa_config, first public revision

#287 Post by Ibidem »

I've written a first pass at a wpa_config tool.
Note: this is intended for configuring wpa_supplicant, with a couple convenient extensions thrown in. It is not a network manager, though for the purpose of wireless networks it fills most of what I need.
I've tested it lightly using dialog; in theory, it should also work with Xdialog or whiptail.
To use another dialog, you would need to add a line setting DIALOG.
gdialog or zenity will not work, due to being barely compatible with ancient versions of dialog.
kdialog might or might not work; reports appreciated.
The "help" text at the top may not be very intelligeable to someone who isn't ready to configure wpa-supplicant with their text editor; if you can think of better wording or find it unclear, please comment.
Connecting to hidden networks is almost certainly broken and unsupported; I have none to test on.
If someone who has hidden networks in their area could run this:

Code: Select all

wpa_cli scan
wpa_cli scan_results >wpascanresults.txt
and provide the contents of wpascanresults.txt, that would be helpful.
If desired, I can make it only show wireless interfaces by default.

Code: Select all

#!/bin/sh
#
# wpa_config script by Isaac Dunham
# written and released into public domain under CC0 in 2014
#
# I expressly disclaim ANY WARANTEE IMPLIED OR STATED, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARANTEES OF MERCHANTABILITY OR
# FITNESS FOR A PARTICULAR PURPOSE.
#
# wpa_config aims to be a dialog-based script for configuring wpa_supplicant
# with some aspects of a network manager thrown in.
# However, it stops short at starting/stopping/restarting wpa_supplicant
# itself; we leave that to system services.

mkdir -m 0700 -p /tmp/wpaconf || rm /tmp/wpaconf &&\
mkdir -m 0700 -p /tmp/wpaconf || {
	echo "Cannot obtain private tempdir!"
	exit 1
}

#DIALOG must implement:
# --insecure --output-fd --passwordbox --menu --inputbox --msgbox --fselect
# --insecure means "show asterisks"; I figure most people want that much acknowledgement.
# --fselect support is only needed for a couple features (user specified config files)

test -n "$DISPLAY" && DIALOG=`command -v Xdialog`
test -z "$DIALOG" && DIALOG=`command -v dialog`
# Unfortunately I have to live with whiptail...
test -z "$DIALOG" && DIALOG=`command -v whiptail`

newconf(){
echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=0" >$NEWCF
}

loadconfig(){
true >$CTRL
LOADCONFS="`[ -e /etc/wpa_supplicant/wpa_supplicant.conf ] && echo global /etc/wpa_supplicant/wpa_supplicant.conf`"
LOADCONFS="$LOADCONFS `[ -e /etc/wpa/$IFCUR.conf ] && echo local /etc/wpa/$IFCUR.conf`"
$DIALOG --output-fd 3 --menu "Which config file do you want to load?" 0 0 0 \
	$LOADCONFS other "browse for file" new "no file" 3>$CTRL
read conf <$CTRL
case $conf in
	new)	newconf
	;;
	global)	cat /etc/wpa_supplicant/wpa_supplicant.conf >$NEWCF
	;;
	local)	cat /etc/wpa/$IFCUR.conf >$NEWCF
	;;
	other)	true >$CTRL
		$DIALOG --output-fd 3 --fselect /etc 20 60 3>$CTRL
		read conf <$CTRL
		case "$conf" in
			*.conf)	true >$NEWCF
				grep ^ctrl_interface "$conf" >/dev/null || newconf
				cat "$conf" >>$NEWCF
			;;
			*)	$DIALOG --msgbox "No valid config file specified!" 0 0
			;;
		esac
	;;
esac
}

saveconfig(){
true >$CTRL
$DIALOG --output-fd 3 --menu \
"Choose a config file to write. WARNING! This WILL IMMEDIATELY OVERWRITE the file!" 0 0 0 \
	 global /etc/wpa_supplicant/wpa_supplicant.conf \
	 local /etc/wpa/$IFCUR.conf other "browse for file" 3>$CTRL
read conf <$CTRL
case $conf in
	global)	cat $NEWCF >/etc/wpa_supplicant/wpa_supplicant.conf
	;;
	local)	cat $NEWCF >/etc/wpa/$IFCUR.conf
	;;
	other)	true >$CTRL
		$DIALOG --output-fd 3 --fselect /etc 20 60 3>$CTRL
		read conf <$CTRL
		case "$conf" in
			*.conf)	cat $NEWCF >"$conf"
			;;
			*)	$DIALOG --msgbox "No valid config file specified!" 0 0
			;;
		esac
	;;
esac
}


setif(){
true >$CTRL
$DIALOG --output-fd 3 --menu "Select an interface:" 0 0 0 `ls /sys/class/net |sed -e 's/^\(.*\)$/\1 \1/g'` 3>$CTRL
read net <$CTRL
export IFCUR=${net:-$IFCUR}
unset net
}

net_add_open() {
true >$CTRL
test -z "$1" && $DIALOG --output-fd 3 --inputbox "Enter the SSID you wish to connect to.\nIf you enter 'any', the computer will\nconnect to any open network." 0 0 any 3>$CTRL
read net <$CTRL
test -n "$1" && net=$1
test -n "$net" || return
echo "network={" >> $NEWCF
case $net in
	any) ;;
	*) echo '	ssid="'"$net"'"' >>$NEWCF
	;;
esac
echo '	key_mgmt=NONE' >>$NEWCF
echo '}' >>$NEWCF
}

net_add_wep(){
true >$CTRL
$DIALOG --output-fd 3  --insecure --passwordbox "Enter the WEP key for SSID: $1"  0 0 3>$CTRL
test `wc -c <$CTRL` -gt 0 || return
cat >>$NEWCF <<EOF
network={
	ssid="$1"
	key_mgmt=IEEE8021X
	eap=MD5
	wep_key0=`cat $CTRL`
}
EOF
echo done >$CTRL
}

net_add_wpa() {
true >$CTRL
$DIALOG --output-fd 3  --insecure --passwordbox "Enter the passphrase for SSID: $1"  0 0 3>$CTRL
test `wc -c <$CTRL` -gt 0 || return
wpa_passphrase $1 <$CTRL >>$NEWCF
echo done >$CTRL
}

network_add() {
true >$CTRL
$DIALOG --output-fd 3 --inputbox "Enter the SSID you wish to connect to." 0 0 3>$CTRL
read net <$CTRL
test -n "$net" || return
true >$CTRL
$DIALOG --output-fd 3 --menu "Choose the network encryption:" 0 0 0 \
	No encryption WEP encryption WPA encryption 3>$CTRL || return
case `cat $CTRL` in
	No)	net_add_open $net
	;;
	WEP)	net_add_wep $net
	;;
	WPA)	net_add_wpa $net
	;;
esac
}

#scanner:
# scan
# save results to file
# parse from file
#Buttons:
#Refresh/Add/Leave
# Usage: IFCUR=if0 scanner
scanner() (
if test OK != "`wpa_cli -i "$IFCUR" scan `"
  then
    $DIALOG --msgbox "wpa_cll status for $IFCUR failed!" 0 0
    return
  fi
net=Rescan
while test -n "$net"
do
  case $net in
    Rescan)
      SCAN=`mktemp /tmp/wpaconf/scanXXXXXX`
      SCAN2=`mktemp /tmp/wpaconf/scanXXXXXX`
      wpa_cli -i "$IFCUR" scan_results >$SCAN

      echo '$DIALOG --output-fd 3 --menu "Select a network to connect to, or rescan." 0 0 0 \' >$SCAN2
      cat $SCAN |awk '{if (NF==5) print $1 "\t\""$5"\" \\";
                  else if (NF==4) print $1 "\t\"" $4"\" \\"; }' >>$SCAN2
      echo 'Rescan "for more networks" 3>$CTRL' >>$SCAN2
      true >$CTRL
      . $SCAN2
      read net <$CTRL
      ;;
    *:*:*:*)
      NET="`awk '{if ($1 == "'$net'") print $NF}' <$SCAN`"
      #network_add $NET
      case `awk '{if ($1 == "'$net'") if (NF == 5) print $4; else print "open"}' <$SCAN` in
      	*WPA*PSK*) net_add_wpa $NET
	;;
	*WEP*) net_add_wep $NET
	;;
	open) net_add_open $NET
      esac
      net=Rescan
      ;;
   esac
done
rm -f $SCAN $SCAN2
)

#initialize before main loop
CTRL=`mktemp /tmp/wpaconf/ctrlXXXXXX`
cmd=maindummy
NEWCF=`mktemp /tmp/wpaconf/confXXXXXX`
newconf
setif
test -n "$IFCUR" || exit 1

#Now, main loop:
while test -n "$cmd"
	do	true >$CTRL
		exec 3>$CTRL
		$DIALOG --output-fd 3 --menu "Select an operation:" 0 0 0 \
		  1 scan 2 disconnect 3 reassociate \
		  4 "change interface ($IFCUR)" 5 "add network" \
		  6 "load new config file" 7 "save config file" 8 "view config file"
		exec 3<&-
		read cmd <$CTRL
		case $cmd in
			1) scanner
			;;
			2) wpa_cli -i $IFCUR disconnect
			;;
			3) wpa_cli -i $IFCUR reassociate
			;;
			4) setif
			;;
			5) network_add
			;;
			6) loadconfig
			;;
			7) saveconfig
			;;
			8) $DIALOG --scrollbar --textbox $NEWCF 0 0
			;;
		esac
	done

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#288 Post by technosaurus »

It looks ok, except some bashisms:
command -v , can be removed if you don't have quoted args inside of args
if you need to run a program with a built list of args you can do this:
args="\"first arg\""
args="${args} \"second arg\""
#...
eval $MYCOMMAND "$args"

for open/wep wife, iw is the best tool I have come across (permissive license and well maintained)
http://wireless.kernel.org/en/users/Documentation/iw
built with libnl-tiny instead of the gpl'd netlink libs:
https://github.com/sabotage-linux/libnl-tiny

I have done a lot of further development on my MIME-type detector. All of the types are hard-coded but doing so gains a couple of orders of magnitude of speed over that _other_ tool (file + libmagic) by doing a binary search on inbuilt sorted values vs. a series of linear searches on xml-derived data. Feel free to mod it for your desktop environment or web server (its initial purpose was to quickly output the Content-type: ) It initially tries to guess the mime-type by file extension for speed (no file opening==no delay), then by magic@offset if not compiled with -DNO_MAGIC.
For a test program compile with:
gcc -DTEST -Os -fmerge-all-constants -fno-asynchronous-unwind-tables -fno-unwind-tables -o MIME3 MIME3.c -s
Available on Github
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#289 Post by Ibidem »

technosaurus wrote:It looks ok, except some bashisms:
command -v , can be removed if you don't have quoted args inside of args
if you need to run a program with a built list of args you can do this:

Code: Select all

args=""first arg""
args="${args} "second arg""
#...
eval $MYCOMMAND "$args"
command -v is POSIX not bash; it's the equivalent of which (which is a Linuxism).
The point there is:
Is there an executable for such-and-such dialog version?
It will return nothing if it's not found, the path if it is found.
for open/wep wife, iw is the best tool I have come across (permissive license and well maintained)
http://wireless.kernel.org/en/users/Documentation/iw
built with libnl-tiny instead of the gpl'd netlink libs:
https://github.com/sabotage-linux/libnl-tiny
First, libnl-tiny is originally an OpenWRT project, consisting simply of a partial fork of libnl 2.
As such, it is under the exact same license: LGPL 2.1.
libnl 3 is under LGPL 2.1 as well.
By the way, I'd like to say that libnl has a pretty responsive upstream; when I sent them a patch to make it work with musl (back in the early 0.9.x timeframe), I got a "thanks, applied" the next day.

Second, iw is not compatible with wext. This means it's out unless you have a recent kernel and in-kernel drivers.

Third, using iw is not going to simplify things.
wpa_config is intended to configure wpa_supplicant to connect to any network you want; wpa_supplicant is what I'm using because it's persistent, it supports all types of wireless networks, it's permissively licensed (BSD-style), and adding a persistent network doesn't take writing a script that you have to run at boot/manually, with a hacked-up parser to figure out whether you even can find the network you want, a case statement that really has to be modified manually if you want to handle roaming, and perhaps another hacked up parser to figure out if you've connected, plus the logic to start a dhcp client.

(That's what it takes to use iw/iwconfig properly, though if you only have one network you ever use and don't have any concerns about kernel panics you could set things up in two lines.)

When I was at the university, I had to have two wireless networks: one for home, one for school. The one at home was wpa, while school had an open network.
wpa_supplicant can connect to the right one automatically, with just this much configuration:

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=network
network={
   ssid="school"
   key_mgmt=NONE
}
#autogenerated by wpa_passphrase wpa password
network={
	ssid="wpa"
	#psk="password"
	psk=3d2e41dbc74080cdb861baf815d70488312e6581b64f44bb2785db5c5a2f27bd
}
It's simpler to handle the errors and it works better (roaming, persistence, reassociation after dropped connections), so I want to make it even easier to use.
I have done a lot of further development on my MIME-type detector. All of the types are hard-coded but doing so gains a couple of orders of magnitude of speed over that _other_ tool (file + libmagic) by doing a binary search on inbuilt sorted values vs. a series of linear searches on xml-derived data. Feel free to mod it for your desktop environment or web server (its initial purpose was to quickly output the Content-type: ) It initially tries to guess the mime-type by file extension for speed (no file opening==no delay), then by magic@offset if not compiled with -DNO_MAGIC.
For a test program compile with:
gcc -DTEST -Os -fmerge-all-constants -fno-asynchronous-unwind-tables -fno-unwind-tables -o MIME3 MIME3.c -s
Available on Github
Neat.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#290 Post by technosaurus »

Turns out the bashism checker i used had a bug report filed stating as such:
https://bugs.debian.org/cgi-bin/bugrepo ... bug=733511

I think Iguleder is using a ksh derivative (loksh) until toysh is complete

libnl-tiny seems to have lost the license file, I noticed the lgpl reference after the post in a random file, so unless it has a static linking exception that eliminates iw.
I had it in my mind that wpa_sup could't do wep, but just noticed /usr/share/doc/wpasupplicant/examples/wep.conf ... so disregard ... though openBSD's ifconfig seems workable too.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#291 Post by Ibidem »

technosaurus wrote:Turns out the bashism checker i used had a bug report filed stating as such:
https://bugs.debian.org/cgi-bin/bugrepo ... bug=733511

I think Iguleder is using a ksh derivative (loksh) until toysh is complete

libnl-tiny seems to have lost the license file, I noticed the lgpl reference after the post in a random file, so unless it has a static linking exception that eliminates iw.
I had it in my mind that wpa_sup could't do wep, but just noticed /usr/share/doc/wpasupplicant/examples/wep.conf ... so disregard ... though openBSD's ifconfig seems workable too.
loksh is openbsd pdksh, with s/\(str\)l\(c[ap][ty]\)/\1n\2/ being the main change besides disabling suspend and mknod builtins.

To be precise, using strn* like strl* is an off-by-one error; also, musl provides the strl* functions. I use the slack-builds patches for openbsd-ksh with -lbsd removed.

As far as WEP goes, you can look at my script. I've used wpa_supplicant with open, wep, and wpa.

wpa_supplicant can be built with no external dependencies; it needs a crypto library, with openssl, gnutls, or an internal one based on tomcrypt being the three options. (You can disable crypto, but that's nearly useless.)
wext is adequate, though libnl/libnl-tiny can be used.
readline can be used, or internal line editing code (which is quite adequate).
dbus, pcap, and several other things are optional on Linux.

so, a permissively-licensed rootfs:
musl
(pd/openbsd-/lo/m)ksh
toybox (init, utils, ifconfig, route...)
wpa_supplicant
optional libarchive, xz, bzip, zlib
axtls/openssl
curl
tinyxlib, tinyxserver
term of the day (xterm or urxvt)
w3m (only mit-licensed browser, IIRC; there may be one other lightweight...but I can't build w3m)
nvi, One True AWK/mawk/heirloom nawk, nbsd sed
fltk, tcl/tk

ast license is compatible, but the code is not easy to get running.
dialog is lgpl, though ncurses is MIT. pdcurses is PD+MIT, bsd curses is BSD.

User avatar
Iguleder
Posts: 2026
Joined: Tue 11 Aug 2009, 09:36
Location: Israel, somewhere in the beautiful desert
Contact:

#292 Post by Iguleder »

Ibidem wrote:
technosaurus wrote:I think Iguleder is using a ksh derivative (loksh) until toysh is complete
Nope - I use OpenBSD's ksh just because it's small, Bash-compatible (still haven't had a single incompatibility) and battle-tested. I don't see any reason to switch.
Ibidem wrote: so, a permissively-licensed rootfs:
musl
(pd/openbsd-/lo/m)ksh
toybox (init, utils, ifconfig, route...)
wpa_supplicant
optional libarchive, xz, bzip, zlib
axtls/openssl
curl
tinyxlib, tinyxserver
term of the day (xterm or urxvt)
w3m (only mit-licensed browser, IIRC; there may be one other lightweight...but I can't build w3m)
nvi, One True AWK/mawk/heirloom nawk, nbsd sed
fltk, tcl/tk
Pretty close to DSLR's package selection, except OpenBSD's awk and FLTK (C++ - you'll need a STL) and tcl (what for?).
[url=http://dimakrasner.com/]My homepage[/url]
[url=https://github.com/dimkr]My GitHub profile[/url]

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#293 Post by technosaurus »

Iguleder wrote:... and tcl (what for?).
tk is the only (formerly) widely used permissively licensed widget toolkit.

Alternatives:
1. tekui -http://tekui.neoscientists.org/ uses lua
- if you prefer javascript over lua, tekui could be ported to js using a bit of duktape
(literally see https://github.com/svaarala/duktape its built quite similar to lua)
2. nsfb based toolkit (http://git.netsurf-browser.org/libnsfb. ... /svgtiny.c) This would require some work but supports many backends includint linux fb, xcb and wayland - like a simplified version of SDL
3. <geek stuff> use only the framebuffer http://litcave.rudi.ir/ - the fbvis musl-static compiles down to 50kb if only stb_image is used (light patch required ~3 lines in fbvis.c and modify 1 line in the makefile) there are several other tools there too, but I didn't want to build ffmpeg at the time ... I wonder how hard it would be to port tinyX11 to use the framebuffer directly using memmaped files and a simple inotify blitter daemon in place of the xserver (wait that sounds like the v9fb/l9fb projects) ... again anything "new" we want to do was probably done 20+ yrs ago at bell labs
</geekstuff>

Re: C++ - I'm not opposed to including (just programming with) a lightweight STL like https://github.com/msharov/ustl which looks like it is very light and would be a nice complement to musl. The author has also done some good work with xcb (neat game ->https://github.com/msharov/gjid) and opengl (can build static binaries without Mesa and operate remotely https://github.com/msharov/gleri)
An STL is needed for many other lightweight tools, libstdc++ just makes them heavier than they should be.

Side note: I finally got my ultralight static libc working on 64bit (I didn't realize the syscall mappings are completely different - which is why the mount program failed before - it was actually calling access())
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#294 Post by Ibidem »

Iguleder wrote:
Ibidem wrote:
technosaurus wrote:I think Iguleder is using a ksh derivative (loksh) until toysh is complete
Nope - I use OpenBSD's ksh just because it's small, Bash-compatible (still haven't had a single incompatibility) and battle-tested. I don't see any reason to switch.
Ibidem wrote: so, a permissively-licensed rootfs:
musl
(pd/openbsd-/lo/m)ksh
toybox (init, utils, ifconfig, route...)
wpa_supplicant
optional libarchive, xz, bzip, zlib
axtls/openssl
curl
tinyxlib, tinyxserver
term of the day (xterm or urxvt)
w3m (only mit-licensed browser, IIRC; there may be one other lightweight...but I can't build w3m)
nvi, One True AWK/mawk/heirloom nawk, nbsd sed
fltk, tcl/tk
Pretty close to DSLR's package selection, except OpenBSD's awk and FLTK (C++ - you'll need a STL) and tcl (what for?).
Have you built w3m?

Speaking of loksh: when you replace strl* with strn*, you need to subtract one from the 'n' arg. strl* will copy no more than "as much as fits in a null-terminated string occupying an n byte array".
strn* will copy "as many chars as fit in an n byte array".
As a result, s/strl/strn/ causes breakage when you hit oversize strings: it won't overflow itself, but the new string will not be null-terminated. As a result, the next operation may read from an invalid address, overestimate the length, or otherwise break.
Also, if the return value of strl* is checked, there will be massive breakage: strn* returns an address, while strl* returns number of bytes.
musl included strl* because they make it easier to write safe programs.

Incompatabilities with bash do exist; I think shell arrays are one of them. (Try http://www.tldp.org/LDP/Bash-Beginners- ... 10_02.html in loksh.) But most of the "bash features" people talk about were copied from one version of ksh or another. ksh93 (which I haven't managed to build...) has a number of features that aren't even available in bash, like floating-point shell math like $((7*7*3.14)).
mksh has copied several of them.

tcl is as a scripting language and a GUI toolkit (actually, tk is the latter part).
There are quite a few programs written using tk, and it's easy to write more.
Athena (Xaw) is also permissively licensed.
Speaking of which...I'm tempted to try a lua/tk or wish version of wpa_config. But that's probably rash at this point.

It seems OpenBSD awk is the One True AWK with several patches.
("One True AWK" is the latest release of awk from the original authors. It's (C) Lucent, under a BSD-like license.)

User avatar
Iguleder
Posts: 2026
Joined: Tue 11 Aug 2009, 09:36
Location: Israel, somewhere in the beautiful desert
Contact:

#295 Post by Iguleder »

Ibidem wrote:Speaking of loksh: when you replace strl* with strn*, you need to subtract one from the 'n' arg. strl* will copy no more than "as much as fits in a null-terminated string occupying an n byte array".
strn* will copy "as many chars as fit in an n byte array".
As a result, s/strl/strn/ causes breakage when you hit oversize strings: it won't overflow itself, but the new string will not be null-terminated. As a result, the next operation may read from an invalid address, overestimate the length, or otherwise break.
Also, if the return value of strl* is checked, there will be massive breakage: strn* returns an address, while strl* returns number of bytes.
musl included strl* because they make it easier to write safe programs.
Thanks for the feedback! Fixed.
Ibidem wrote:Incompatabilities with bash do exist
Of course, Bash always has more surprises up its sleeve. Still haven't encountered even a single incompatibility issue.

I used tcsh before I ported over OpenBSD's shell, but it was kinda big and felt "different". ksh feels like Bash or the Busybox ash.
Ibidem wrote:tcl is as a scripting language and a GUI toolkit (actually, tk is the latter part).
What's so bad about GTK+ 1.x and GtkDialog1, except GPL?
[url=http://dimakrasner.com/]My homepage[/url]
[url=https://github.com/dimkr]My GitHub profile[/url]

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#296 Post by technosaurus »

Iguleder wrote:Of course, Bash always has more surprises up its sleeve. Still haven't encountered even a single incompatibility issue.
...
What's so bad about GTK+ 1.x and GtkDialog1, except GPL?
Like bashdiff ... it (and the 3.x bash series) should really be a Puppy/Slitaz maintained project to replace gtkdialog, sqlite3 shell, hiawatha, and numerous other tools.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#297 Post by Ibidem »

Iguleder wrote:
Ibidem wrote:Incompatabilities with bash do exist
Of course, Bash always has more surprises up its sleeve. Still haven't encountered even a single incompatibility issue.

I used tcsh before I ported over OpenBSD's shell, but it was kinda big and felt "different". ksh feels like Bash or the Busybox ash.

Agreed. (t)csh is a shell in function, but it's got little in common with the Bourne-like shells. And bash and the various ksh versions are the most closely related shells, syntax-wise.

History as far as I can tell: Bourne was ~first (barring some ancient versions that act very different), Korn wrote an "improved" version called ksh (or ksh88, since it was released in 1988), someone copied Bourne to make the first version of bash, someone started copying ksh to make pdksh, POSIX borrowed from ksh onto Bourne to make Posix sh, bash implemented that and kept borrowing from ksh, Korn wrote a bigger version with tons of features (called ksh93); bash and ksh have been borrowing from each other since, though most new stuff happens in ksh93 now; meanwhile, Almquist implemented a POSIX shell (ash), which got ported to Linux and eventually forked as dash. bash has borrowed a couple small details from csh (&> is the main one). zsh is a HUGE shell that aims to act like any and every other shell, with the ability to imitate bash, ksh, and csh, plus several extensions; but it's not without bugs.
Ibidem wrote:tcl is as a scripting language and a GUI toolkit (actually, tk is the latter part).
What's so bad about GTK+ 1.x and GtkDialog1, except GPL?
I was describing a permissively licensed rootfs; "except GPL" is plenty of reason for that, though I don't mind using GPL software. (It's sometimes fun to pick a semi-arbitrary limit and figure out what you can do within it.)
But there are a couple slightly more technical reasons than that.
gtkdialog1: just a TLA that rhymes with "hell": XML.
Having on occasion tried to edit XML config files by hand, I'm eager to stay as far away as possible. I'm certainly not excited about the prospect of writing and maintaining a program done in XML.

I rather like using gtk1 software, but gtk1 is not really all that widely distributed (and likewise for gtkdialog*); also, glib can get annoying.

Additionally, gtk and gtkdialog are much more verbose than Tcl/Tk. I'm afraid I can't give an example for this off the top of my head, though.

Completely off topic: I presume all the trouble we've been hearing about in the news is a fair distance from you?

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#298 Post by jamesbond »

Ibidem wrote:I was describing a permissively licensed rootfs; "except GPL" is plenty of reason for that, though I don't mind using GPL software.
Another off-topic, but related to the license thing: I happen to be trying to build MariaDB (the offshot of what was originally MySQL).
And look at what the kind of FUD they put into CMakeList.txt:
MariaDB CMakeList.txt wrote:IF(NON_DISTRIBUTABLE_WARNING)
MESSAGE(WARNING "
You have linked MariaDB with GPLv3 libraries! You may not distribute the resulting binary. If you do, you will put yourself into a legal problem with Free Software Foundation.")
ENDIF()
And this is from someone who made US$1billion from creating GPL software in the first place :evil: (For those not in the know: MariaDB is created as a fork of MySQL. MariaDB is created by the very same person who created MySQL - he sold GPL-ed MySQL to Oracle for $1billion, was happy with the money but not happy that he no longer had any say in MySQL, so he created the MariaDB fork and has been woo-ing people to drop MySQL in favour of MariaDB - so that perhaps once its popular enough he can sell it again for the second time for another $1billion to IBM or Apple or Microsoft, this time).

It's one thing to disagree with GPL or GPLv3 or even its principles; it's another thing to tell blatant lies in a supposedly high-profile GPL-ed software like this :evil: (and as I said - especially from someone who profited from it).
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
Iguleder
Posts: 2026
Joined: Tue 11 Aug 2009, 09:36
Location: Israel, somewhere in the beautiful desert
Contact:

#299 Post by Iguleder »

Ibidem wrote:Having on occasion tried to edit XML config files by hand, I'm eager to stay as far away as possible. I'm certainly not excited about the prospect of writing and maintaining a program done in XML.
Agreed, I hate XML too. Other formats (like JSON) make things just a little bit simpler, because they're cleaner (e.g you don't have to close tags).
Ibidem wrote:I rather like using gtk1 software, but gtk1 is not really all that widely distributed (and likewise for gtkdialog*); also, glib can get annoying.
Yep, C++ imitations in C are horrible by definition.
Ibidem wrote:Completely off topic: I presume all the trouble we've been hearing about in the news is a fair distance from you?
40 km from me, I hear and feel every rocket fired and every air strike.
jamesbond wrote:And this is from someone who made US$1billion from creating GPL software in the first place :evil:
Generally, I believe in "live and let live". I don't like the fact GPL is viral, so I license my own code under BSD (if it's useful for commercial projects - I get some reputation) or make it public domain (if it isn't).

However, GPL/BSD is not a consideration when I have to decide which packages should be included in a distro, unless it's an evil GPL project (e.g a project owned by a company, with a CLA).
[url=http://dimakrasner.com/]My homepage[/url]
[url=https://github.com/dimkr]My GitHub profile[/url]

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#300 Post by technosaurus »

Ibidem wrote:Additionally, gtk and gtkdialog are much more verbose than Tcl/Tk. I'm afraid I can't give an example for this off the top of my head, though.
Biggest thing, NO SANE DEFAULTS
Completely off topic: I presume all the trouble we've been hearing about in the news is a fair distance from you?
huh?, didn't see anything on slashdot, whats up?

... I am really starting to like tekui and lua. Lua isn't bad once you get used to it, but I still may port tekui to javascript with duktape since the interface already uses css and it can handle xml and json - if ported from lua to javascript, you've got a nice little web browser in 100+ lines of code.
jamesbond wrote:It's one thing to disagree with GPL or GPLv3 or even its principles; it's another thing to tell blatant lies in a supposedly high-profile GPL-ed software like this :evil: (and as I said - especially from someone who profited from it).
<rant>
Technically they are right. GPL2 is incompatible with GPL3, so if you link a GPL2 only library (without the "or any later version" clause), then you are violating the GPL. GPL3 demonstrated in one fell swoop how dangerous that clause can be. Manufacturers who had been contributing to GPL software and properly distributing the source could no longer use the new version because they had been installing it to ROM for cost and performance reasons (ROM which the end user could't possibly modify) ... That pretty much eliminated the embedded market and things have gone down hill from there. I mainly try to avoid using anything from the FSF or other entities with legal documents over 1 page because I don't have my own personal team of lawyers to help me comply (or figure out if it is even possible to comply ... can you even build GPL3 software against the linux kernel headers?).
</rant>

Re: shells
I think it would be nice to have something basic for common languages
python -> tinypy
tcl -> jim-tcl
js -> duktape/quadwheel/libsee/spidermonkey-1.8.0b1
lua -> stua (part of stb), luajit or even plain lua, its pretty small already
java -> avian
perl -> microperl
c -> tcc
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Post Reply