Am Freitag, 13. Mai 2022, 13:21:17 CEST schrieb Stefan Krusche: Hi Stefan, I believe, changing the ifup-script might be a good idea. Additionally I will try to set the environment variable in /etc/default/macchanger to my needs.
At the moment I am using a random MAC set by network-manager, but this one is always the same, what I also do not want. As I would like to forget about changing my MAC whenever I am online, macchanger looks like the best solution. In the meantime I filed a buugreport to it, because as we see, macchanger does not do its job by default as intended. So it is indeed buggy! Or let's say: Its configuration and scripts are buggy. I will also take a look at your script, maybe this will work, too. Thank you for the help! Best regards Hans > Good Day Everyone, > > Am Montag, 9. Mai 2022 schrieb Hans: > > IFACE = --all > > /usr/bin/macchanger: unrecognized option '--all' > > GNU MAC Changer > > Yes. The problem is that the script /etc/macchanger/ifupdown.sh which is > shipped with the macchanger package processes $IFACE without checking > its value. > > package=macchanger > /usr/bin/${package} -e $IFACE >> $LOGFILE 2>&1 > > When $IFACE == "--all" which is a valid option for ifup as David pointed > out then macchanger fails and reports the above error message to its > logfile because macchanger understands "--all" as on option which it > doesn't know. > > Am Montag, 9. Mai 2022 schrieb David Wright: > > A workaround for your problem might be to set IFACE appropriately > > in /etc/default/macchanger. > > A solution I found is to change the script /etc/macchanger/ifupdown.sh > so that it checks for the value of $IFACE against the value of > $ENABLE_INTERFACES (sourced from /etc/default/macchanger) and only then > processes that accordingly. $ENABLE_INTERFACES on my system contains > only "net0" so all is fine here. > > A version of this script which works on my system (Devuan Beowulf) is > attached. > > Another approach I haven't tested yet could be to add "--" to the line > which invokes maccanger so that the value of "$IFACE" being "--all" > wouldn't be treated as an option but as an argument and given to ifup > or whatever macchanger internally uses to actually change the MAC. But > I don't know if macchanger understands "--". > > /usr/bin/$package -a -- "$IFACE" >> $LOGFILE 2>&1 > > HTH > > Kind regards, > Stefan > > > > $ cat /etc/macchanger/ifupdown.sh > #!/bin/sh > # $Id: ifupdown.sh,v 2.0 2021-04-21 16:23:42+02 stekru Exp $ > # randomize MAC address before connecting to wifi or ethernet > # > # This script should always be run in if-pre-up.d, but unfortunately > # NetworkManager does not run if-pre-up.d scripts before it sets up a > network > # connection (https://bugzilla.gnome.org/show_bug.cgi?id=387832). > # if-post-down.d scripts are run, so there is a symlink to this script > # there. That means when running network config from the terminal, > macchanger > # will be run twice, but it'll only be run in if-post-down.d when using > # NetworkManager. > > package=macchanger > LOGFILE=/var/log/$package.log > #LOGFILE=~/.local/log/$package.log > > echo >> $LOGFILE > date '+%Y-%m-%d %T' >> $LOGFILE > > # Vorgaben einlesen; hier wird auch ENABLE_INTERFACES="net0" eingelesen. > if [ -f /etc/default/$package ]; then > . /etc/default/$package > else > echo "Config file /etc/default/$package not found" >> $LOGFILE > exit 1 > fi > > if [ "$ENABLE_ON_POST_UP_DOWN" != "true" ]; then > echo "Macchanger is disabled in /etc/default/$package" >> $LOGFILE > exit > fi > > # Where comes '$IFACE' from? From networking or ifup/-down/-query? > # The variable could be read from the environment. Where (from which > # program) would it be exported. No arguemnts are being processed here. > echo "Processing: IFACE = $IFACE" >> $LOGFILE > > if [ -z "$ENABLE_INTERFACES" ]; then > echo "No interface enabled in /etc/default/$package" >> $LOGFILE > exit 0 > else > case "$IFACE" in > *$ENABLE_INTERFACES*) > /usr/bin/$package -a "$IFACE" >> $LOGFILE 2>&1 > ;; > *) > echo "Ignoring not configured interface: $IFACE" >> $LOGFILE > exit 0 > ;; > esac > fi