Jump to content

Bug/Changed behaviour in 4.6?


Recommended Posts

Hi There,

 

On macOS 11.6 build 20G165 (on M1 laptop) with Alfred 4.6 Build 1266 there is a slight change in the running of workflows as it seems. I most note I also have Little Snitch version 5.3.1 installed. Little Snitch is an outbound firewall so to say for MacOS.

 

Before I installed Alfred Build 4.6 and I ran my workflow "runChrome" which has options to run a new empty Chrome profile, ignore all TLS Errors and/or with a proxy for SSH port forward enabled this worked fine with Little Snitch as Little Snitch used the rules defined for Chrome.

 

Now since Alfred 4.6, at least I think that's what triggered it, when I run Chrome via this workflow, Little Snitch is asking to grant outbound network access to Alfred instead of Chrome for the actual Chrome process/Window.

 

My guess is that with Alfred 4.6 the way a script is launched from the workflow is different than the previous Alfred 4.5.1, almost like it's a full child process and doesn't get spawned as a more or less disconnected process. I did check to see if there was an option like this on the workflow, but I don't believe so.

 

As I can't attach the workflow, here is the code, this all there is to the workflow and script.

 

Please advice if something changed in 4.6, happy to debug / test further but would need some guidance how to do this in Alfred, as the log window for the workflow only said:

Quote

 

[20:49:44.068] Logging Started...

[20:49:51.243] Run Chrome[List Filter] Processing complete

[20:49:51.247] Run Chrome[List Filter] Passing output 'fresh' to Run Script

 

 

 

Thanks in advance!

Stijn

 

Workflow:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>bundleid</key>
        <string>nl.sjc.runChrome</string>
        <key>category</key>
        <string>Productivity</string>
        <key>connections</key>
        <dict>
                <key>F89ECEC3-23A4-42A9-BDD2-694AE847EB41</key>
                <array>
                        <dict>
                                <key>destinationuid</key>
                                <string>9452871A-321F-4B2B-9941-99CAF74D947C</string>
                                <key>modifiers</key>
                                <integer>0</integer>
                                <key>modifiersubtext</key>
                                <string></string>
                                <key>vitoclose</key>
                                <false/>
                        </dict>
                </array>
        </dict>
        <key>createdby</key>
        <string>Stijn Jonker</string>
        <key>description</key>
        <string>Launch Chrome</string>
        <key>disabled</key>
        <false/>
        <key>name</key>
        <string>Run Chrome</string>
        <key>objects</key>
        <array>
                <dict>
                        <key>config</key>
                        <dict>
                                <key>argumenttrimmode</key>
                                <integer>0</integer>
                                <key>argumenttype</key>
                                <integer>1</integer>
                                <key>fixedorder</key>
                                <true/>
                                <key>items</key>
                                <string>[{"title":"Fresh","arg":"fresh","subtitle":"Fresh Incognito Profile"},{"title":"FreshProxy","arg":"freshproxy","subtitle":"Fresh Incognito Profile w\/ Proxy"},{"title":"FreshNoCert","arg":"freshnocert","subtitle":"Fresh Incognito Profile no cert check"},{"title":"FreshNoCertProxy","arg":"freshnocertproxy","subtitle":"Fresh Incognito Profile w\/ Proxy no cert check"},{"title":"Proxy","arg":"proxy","subtitle":"Normal Profile w\/ Proxy"}]</string>
                                <key>keyword</key>
                                <string>runchrome</string>
                                <key>runningsubtext</key>
                                <string></string>
                                <key>subtext</key>
                                <string>Which mode would you like to use?</string>
                                <key>title</key>
                                <string>RunChrome</string>
                                <key>withspace</key>
                                <true/>
                        </dict>
                        <key>type</key>
                        <string>alfred.workflow.input.listfilter</string>
                        <key>uid</key>
                        <string>F89ECEC3-23A4-42A9-BDD2-694AE847EB41</string>
                        <key>version</key>
                        <integer>1</integer>
                </dict>
                <dict>
                        <key>config</key>
                        <dict>
                                <key>concurrently</key>
                                <true/>
                                <key>escaping</key>
                                <integer>102</integer>
                                <key>script</key>
                                <string>/Users/sjcjonker/Documents/Scripts/AlfredChromeRun.sh {query}</string>
                                <key>scriptargtype</key>
                                <integer>0</integer>
                                <key>scriptfile</key>
                                <string></string>
                                <key>type</key>
                                <integer>0</integer>
                        </dict>
                        <key>type</key>
                        <string>alfred.workflow.action.script</string>
                        <key>uid</key>
                        <string>9452871A-321F-4B2B-9941-99CAF74D947C</string>
                        <key>version</key>
                        <integer>2</integer>
                </dict>
        </array>
        <key>readme</key>
        <string></string>
        <key>uidata</key>
        <dict>
                <key>9452871A-321F-4B2B-9941-99CAF74D947C</key>
                <dict>
                        <key>xpos</key>
                        <integer>450</integer>
                        <key>ypos</key>
                        <integer>255</integer>
                </dict>
                <key>F89ECEC3-23A4-42A9-BDD2-694AE847EB41</key>
                <dict>
                        <key>xpos</key>
                        <integer>125</integer>
                        <key>ypos</key>
                        <integer>50</integer>
                </dict>
        </dict>
        <key>variablesdontexport</key>
        <array/>
        <key>version</key>
        <string>0.0.1</string>
        <key>webaddress</key>
        <string>www.sjc.nl</string>
</dict>
</plist>

 

The (ugly) shell script called is:

#/Users/sjcjonker/Scripts/AlfredRunChrome.sh {query}
OPT=${1}
# Any command in a pipe fails, then all fail
# Unset variables are an error!
set -u -o pipefail
# Chrome CMDLine for proxy
CHROMEBIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
# --incognito
CHROMEOPT="--incognito --disable-logging --disable-notifications --bwsi --disable-infobars --no-default-browser-check"
# Set chromedir
CHROMEPROFILEDIR="/tmp/ChromeProfiles"
if [ ! -d ${CHROMEPROFILEDIR} ]; then
  mkdir -p ${CHROMEPROFILEDIR};
fi
MYTEMPBASE="RunChrome"
MYTMPDIR=`mktemp -d -q ${CHROMEPROFILEDIR}/${MYTEMPBASE}.XXXXXX`
if [ $? -ne 0 ]; then
  echo "$0: Can't create temp directory, exiting..."
  exit 1
fi
# Disable first run
touch "${MYTMPDIR}/First Run"
echo '{"browser": {"confirm_to_quit": false}}' > "${MYTMPDIR}/Local State"
# Now run Chrome
if [ "${OPT-}" == "fresh" ] ; then
  "${CHROMEBIN}" ${CHROMEOPT} --user-data-dir=${MYTMPDIR}
elif [ "${OPT-}" == "freshproxy" ] ; then
  "${CHROMEBIN}" ${CHROMEOPT} --proxy-server=socks5://127.0.0.1:9998 --host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE 127.0.0.1" --user-data-dir=${MYTMPDIR}
elif [ "${OPT-}" == "freshnocert" ] ; then
  "${CHROMEBIN}" ${CHROMEOPT} --user-data-dir=${MYTMPDIR} --ignore-certificate-errors
elif [ "${OPT-}" == "freshnocertproxy" ] ; then
  "${CHROMEBIN}" ${CHROMEOPT} --user-data-dir=${MYTMPDIR} --ignore-certificate-errors -proxy-server=socks5://127.0.0.1:9998 --host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE 127.0.0.1"
elif [ "${OPT-}" == "proxy" ] ; then
  "${CHROMEBIN}" --proxy-server=socks5://127.0.0.1:9998 --host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE 127.0.0.1"
else
  "${CHROMEBIN}"
fi
# Delete profile dir
rm -R "${MYTMPDIR}"
if [ $? -ne 0 ]; then
  echo "$0: Can't remove temp directory, please check \"${MYTMPDIR}\""
  exit 1
fi

 

 

 

Link to comment
12 hours ago, sjcjonker said:

As I can't attach the workflow, here is the code

 

Upload the workflow to your Dropbox or iCloud drive and post a link.

 

12 hours ago, sjcjonker said:

almost like it's a full child process and doesn't get spawned as a more or less disconnected process.

 

Alfred has never run workflows that way. It can't run workflows as detached processes because it needs to be able to read their output, know when they've finished and what their exit code was.

 

12 hours ago, sjcjonker said:

when I run Chrome via this workflow, Little Snitch is asking to grant outbound network access to Alfred instead of Chrome for the actual Chrome process/Window.

 

I'm pretty sure the only thing that matters is whether Chrome is already running or not.

 

If you execute the binary directly and Chrome is already running, it passes off the command to the running instance and exits immediately. If Chrome isn't already running, it starts a new instance right there, stays attached, and doesn't exit till you quit the application.

 

These two modes seem to correspond fairly precisely with the "old" and "new" behaviours you describe.

Edited by deanishe
Link to comment

Hi Deanishe,

 

Apologies if this hasn't changed then something else surely must have changed. I then need to revisit the updates & actions log I keep to find what else has changed, although I'm certain it started after the update. Maybe two updates coming together, as Chrome is often updated in the background.

 

I'm aware of the passing of by Chrome to the running processes, which none of the "fresh" items in the workflow do. 

 

Thanks for your feedback I'll continue my hunt; but I guess I can rule out Alfred. 

Link to comment
2 hours ago, sjcjonker said:

Apologies if this hasn't changed then something else surely must have changed.

 

I don't know if anything has changed, but I'm certain Alfred doesn't and never has launched detached workflow processes. I believe Alfred uses NSTask to run workflows, and that doesn't even support anything fancy.

 

If LS is now detecting Chrome as a subprocess of Alfred when it wasn't before, it seems far more likely that something has changed in Chrome or LS (or the macOS APIs it uses).

 

I don’t have Big Sur or LS 5, but the “new” behaviour you describe is how previous versions of Little Snitch have worked for many years. If you run curl in a shell, LS asks about “iTerm via curl”. Similarly, it has always asked about “Alfred via <workflow-binary>”. That is exactly the behaviour I would expect if Chrome is really running in the subprocess, not handing off to an already-running instance.

Edited by deanishe
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...