Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED] How can I make an app think it's running in another directory (without merely changing HOME env. var.)?

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
User avatar
s3a
Posts: 831
Joined: 2008-07-17 22:13
Has thanked: 6 times
Been thanked: 2 times

[SOLVED] How can I make an app think it's running in another directory (without merely changing HOME env. var.)?

#1 Post by s3a »

How can I make an app think it's running in another directory (without merely changing HOME environment variable, which doesn't always work, and it also doesn't work with non-home directories)?

Any input would be GREATLY appreciated!
Last edited by s3a on 2022-06-06 09:12, edited 1 time in total.
Use Mnemosyne to Study for School!

User avatar
canci
Global Moderator
Global Moderator
Posts: 2502
Joined: 2006-09-24 11:28
Has thanked: 136 times
Been thanked: 136 times

Re: How can I make an app think it's running in another directory (without merely changing HOME environment variable)?

#2 Post by canci »

CLI tools usually should respect cd PATH or some flag like --path. Many GUI tools also do that.

It's really hard to say though, since you didn't tell us what app you mean.
Image Stable / Asus VivoBook X421DA / AMD Ryzen 7 3700U / Radeon Vega Mobile Gfx (Picasso) / 8 GB RAM / 512GB NVMe

READ THIS:

* How to Post a Thread Here
* Other Tips and Great Resources

User avatar
wizard10000
Global Moderator
Global Moderator
Posts: 626
Joined: 2019-04-16 23:15
Location: southeastern us
Has thanked: 84 times
Been thanked: 98 times

Re: How can I make an app think it's running in another directory (without merely changing HOME environment variable)?

#3 Post by wizard10000 »

Yep - we need a use case to understand what you're trying to do :)
we see things not as they are, but as we are.
-- anais nin

user6c57b8
Posts: 19
Joined: 2022-05-31 16:19
Has thanked: 5 times

Re: How can I make an app think it's running in another directory (without merely changing HOME environment variable)?

#4 Post by user6c57b8 »

s3a wrote: How can I make an app think it's running in another directory?
chdir() #in python/perl/php/C/C++
cd #in bash

Just google 'chdir $your_language_of_choice_here'

User avatar
s3a
Posts: 831
Joined: 2008-07-17 22:13
Has thanked: 6 times
Been thanked: 2 times

Re: How can I make an app think it's running in another directory (without merely changing HOME environment variable)?

#5 Post by s3a »

I don't think any of these answer would do what I need, but thanks anyways.

It seems what I need is to use firejail --noprofile --private=/home/user/fake_home.

For example,

Code: Select all

firejail --noprofile --private=/home/user/fake_home bash
and then, everything would seem like it's being done in /home/user, but it'd really be done in /home/user/fake_home.

Basically, I wanted to sandbox my IDE and toolchain environment (that are from upstream and not in the Debian repositories (because I'm paranoid :P)).

Edit:
I also wanted to isolate the files made from the rest of the system.

P.S.
That doesn't allow one to fool an app into thinking its non-home directories are other than they are, but I don't really need that for my use case anyways.
Use Mnemosyne to Study for School!

Post Reply