Score:0

How to get an aliased command to execute from a menu entry?

in flag

I re-furbish PCs for a small non-profit and we use xubuntu cloned using clonezilla. I am experiencing an issue where I set up an alias:

alias pkexec='pkexec /usr/bin/env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY'

This works fine from the command line and from a menu entry that I edited on my work rig. From my work rig, I get the password prompt that:

Authentication is required to run '/usr/bin/env'  

I enter my password and /usr/bin/hardinfo opens as superuser.

However, when this is attempted on any of my 'clones', pkexec displays the password prompt:

Athentication is required to run /usr/bin/hardinfo 

I enter my password and top show hardinfo starts then crashes or no longer appears as an executing program. I know there is something different between my rig and my clones. I don't know what is it. I'm posting here for your comments and suggestions.

Thanks in advance,

@bacOn,

I set up the function in .bashrc

pkexec() { command pkexec /usr/bin/env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "$@" }

I get a syntax error when I run source .bashrc syntax error unexpected token:

bash: .bashrc: line 146: syntax error near unexpected token `('
bash: .bashrc: line 146: `pkexec(){"command pkexec /usr/bin/env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "$@" "}'

@muru

I modified it and it now works.

pkexec(){ /usr/bin/pkexec /usr/bin/env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "$@" } source .bashrc and boom. it works on my home rig running mint from the commandline. but if I edit a menu entry pkexec /usr/bin/hardinfo, I get the password windows saying that /usr/bin/hardinfo requires authentication to run as root. hardinfo crashes.

But even after all your help, my question still remains, What could have changed on my work rig that would cause a cloned imaged to not work as expected. What troubleshooting steps might assist me in digging into the weeds on an issue that may/may not otherwise affect out future imaged machines.

Thanks for all of your help.

cocomac avatar
cn flag
I'm not sure of the issue, but have you considered taking one of your cloned images, and booting it up in a VM? That might allow you to debug the issue...
Terence Golightly avatar
in flag
No actually, I havn't. I don't think I know how to go about that. I mean I can install virtualbox (what I am familiar with) but actually cloning the image to a vm, I don't know. But I am game to learn.
bac0n avatar
cn flag
use a function instead.
Terence Golightly avatar
in flag
Hi @bac0n, I havn't used/setup a function before. Not sure how that might look like.
bac0n avatar
cn flag
function is use much the same way `pkexec(){ command pkexec env ... ... "$@"; }` you can ethier use `command` as I have done or full path to the real pkexec command or you will get a race condition.
muru avatar
us flag
You need the `;` before the closing `}` if you put the function definition all in one line: https://askubuntu.com/a/521943/158442
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.