I want that the warp script is run everytime root is logged in,not more,not less.
I wouldn't to login as root automatically,but I've realized that this
command :
echo 1 > /proc/sys/net/ipv4/ip_forward
work only if I'm root. It does not work using sudo. So,in the end I've
chosen to be root instead of a normal user that can use sudo.
echo 1 > /proc/sys/net/ipv4/ip_forward
work only if I'm root. It does not work using sudo.This doesn't sound right. Maybe you should investigate why you're
seeing this behavior, rather than work around the problem.
`sudo` *is* root.
echo 1 > /proc/sys/net/ipv4/ip_forward
work only if I'm root. It does not work using sudo.
.profile
will always be read as soon as the user logs in, no matter how. Through a terminal, a GUI, doesn't matter.
If they only want this thing to happen when root logs in directlyon a console or ssh, then .profile may indeed be the correct answer.
Yes,I don't need to run xorg and a desktop environment,since warp-cli disconnect and warp-cli connect do not require them.
I wouldn't to login as root automatically,but I've realized that this
command :
echo 1 > /proc/sys/net/ipv4/ip_forward
work only if I'm root. It does not work using sudo. So,in the end I've
chosen to be root instead of a normal user that can use sudo.
If they only want this thing to happen when root logs in directly on aconsole or ssh, then .profile may indeed be the correct answer.
Yes,I don't need to run xorg and a desktop environment,since warp-cli disconnect and warp-cli connect do not require them.
I wouldn't to login as root automatically,but I've realized that this
command :
echo 1 > /proc/sys/net/ipv4/ip_forward
work only if I'm root. It does not work using sudo. So,in the end I've
chosen to be root instead of a normal user that can use sudo.
Mario Marietto wrote:> If you run
sudo echo 1 > /proc/sys/net/ipv4/ip_forward
then the shell you are running it from will run "sudo echo 1"
and then try to put the output in that file.
[email protected] (12024-05-13):
That's like slicing your morning baguette with the chainsaw.
Worse than that, it will only work from an X11 environment. Certainly
not at boot.
I was experimenting, and found this works:
sudo xterm -e "echo 1 > hello"
It created a file owned by root. But I found I was able to remove it
without being root even though group and world permissions were read
only.
I was experimenting, and found this works:
sudo xterm -e "echo 1 > hello"
That's like slicing your morning baguette with the chainsaw.
I was experimenting, and found this works:
sudo xterm -e "echo 1 > hello"
It created a file owned by root. But I found I was able to remove it
without being root even though group and world permissions were read
only.
Le 13/05/2024 à 14:36, Richmond a écrit :
I was experimenting, and found this works:thats because sudo exceutes a xterm as root
sudo xterm -e "echo 1 > hello"
It created a file owned by root. But I found I was able to remove it
without being root even though group and world permissions were read
only.
then this xterm executes a shell (as root) and this root shell does
the redirection.
sudo bash -c "echo 1 > hello"
Erwan David <[email protected]> writes:
Le 13/05/2024 à 14:36, Richmond a écrit :Yes, but why did it allow me to delete the file? I was not root
I was experimenting, and found this works:thats because sudo exceutes a xterm as root
sudo xterm -e "echo 1 > hello"
It created a file owned by root. But I found I was able to remove it
without being root even though group and world permissions were read
only.
then this xterm executes a shell (as root) and this root shell does
the redirection.
then. Try it.
On Mon, May 13, 2024 at 01:36:23PM +0100, Richmond wrote:
I was experimenting, and found this works:
sudo xterm -e "echo 1 > hello"
That's like slicing your morning baguette with the chainsaw.
But if it works for you... hey :-)
Cheers
The command iptables -A POSTROUTING -t nat -s 192.168.1.5 -j MASQUERADE doesn't work if invoked as a user,it says "you must be root". So,as
user,the script seems to be working fine like this :
function jumpto
{
label=$1
cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
eval "$cmd"
exit
}
On Mon, May 13, 2024 at 02:03:59PM +0100, Richmond wrote:
sudo xterm -e "echo 1 > hello"
Yes, but why did it allow me to delete the file? I was not root
then. Try it.
Because you have write permission on the *directory* that the file is in.
Removing (unlinking) a file is an operation that modifies a directory,
not the file itself. You don't need write permission on the file. Just
the directory.
No need to “investigate”, the answer is obvious: inecho 1 > /proc/sys/net/ipv4/ip_forwardThis doesn't sound right. Maybe you should investigate why you're
sudo xterm -e "echo 1 > hello"
Yes, but why did it allow me to delete the file? I was not root
then. Try it.
You don't need to, but I definitely think he does. 🙂^^
On Mon, May 13, 2024 at 07:36:07AM +0200, Richard wrote:
.profile
Am Montag, 13. Mai 2024, 13:24:17 CEST schrieb Greg Wooledge:
On Mon, May 13, 2024 at 07:36:07AM +0200, Richard wrote:
.profile
Sorry, dumb question: Depending of the shell, the user is using (let's say, he
will use bash), can the script not be added into ~/.bashrc?
If yes, second dumb question: Coiuld it be ANY script or command?
(also running as non-rootuser, like adding "runuser -u myuser command_whatever").
function jumpto
{
label=$1
cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
eval "$cmd"
exit
}
mid :That should be "mid:".
jump fooThat should be "jumpto foo".
There is still a problem. If I login automatically as user and inside
the script I do this :
sudo iptables -A POSTROUTING -t nat -s 192.168.1.5 -j MASQUERADE
it asks me for the password (don't know why it didn't before) but I
can't issue a password,because the script inside the vm should work automatically and should be hidden between the FreeBSD processes.
Am Montag, 13. Mai 2024, 13:24:17 CEST schrieb Greg Wooledge:
On Mon, May 13, 2024 at 07:36:07AM +0200, Richard wrote:
.profile
Sorry, dumb question: Depending of the shell, the user is using (let's say, he
will use bash), can the script not be added into ~/.bashrc?
If yes, second dumb question: Coiuld it be ANY script or command?
(also running as non-rootuser, like adding "runuser -u myuser command_whatever").
On Mon, May 13, 2024 at 9:05 PM Greg Wooledge <[email protected]> wrote:
On Mon, May 13, 2024 at 06:06:37PM +0200, Hans wrote:
Am Montag, 13. Mai 2024, 13:24:17 CEST schrieb Greg Wooledge:
On Mon, May 13, 2024 at 07:36:07AM +0200, Richard wrote:
.profile
Sorry, dumb question: Depending of the shell, the user is using (let'ssay, he
will use bash), can the script not be added into ~/.bashrc?
The context has been snipped out. The context for this was "OP is trying to run a command when root logs in". The method of login was not stated. First responder said ".profile works for every method of login". I said that this is incorrect: it doesn't work for many GUI login setups.
In those same GUI login setups, .bashrc is *also* not read when the
user logs in. None of the shell startup files are read at all.
All of this is a tangent to the actual problem, though.
If yes, second dumb question: Coiuld it be ANY script or command?
(also running as non-rootuser, like adding "runuser -u myuser command_whatever").
We're several layers deep into an X-Y problem here. The *actual* problem is that the system's networking configuration is not correct/complete.
The *workaround* is that the OP is logging in and running commands to change the networking configuration temporarily.
The question resulting from the workaround (the Y in the X-Y) was "How
can I automate these commands that I keep having to type?"
The proper question should have been "How can I fix my system's networking configuration permanently?"
The context has been snipped out....
nope. Read well what I said on my first post :
*[Forgot to say that I switched boot target to text with this command :*
*sudo systemctl set-default multi-user.target]*
What does this mean for you ?
The context is that I was not using any
desktop manager.
Nobody can show a different way,a modern way, for creating my script ? Why did I feel so comfortable by recreating the 1960s GOTO statement in Bash ?
Nobody can show a different way,a modern way, for creating my script ? Why did I feel so comfortable by recreating the 1960s GOTO statement in Bash ?
Your answer does not help me to understand how to use a "structured programming / if , while, for, functions" for the specific task that I want to achieve.
I've installed the Cloudflare gateway on Debian as a vm because I can't do
it directly in FreeBSD. But I want to be covered even when I use FreeBSD.
The script that I wrote forward the Cloudflare "VPN" from Debian to FreeBSD,so from outside my IP will be cloudFlared.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 146:12:06 |
| Calls: | 12,089 |
| Calls today: | 2 |
| Files: | 15,000 |
| Messages: | 6,517,501 |