View mode: basic / threaded / horizontal-split · Log in · Help
May 01, 2012
How to make a directory?
What is the D way to create a directory?

I can use the C function system("mkdir ...") but it doesn't seem 
very good to me.

Also, is there a way to require the root password of the user 
when going create the directory in a restricted folder (like 
/usr) AFTER the application has started?

Thank you.
May 01, 2012
Re: How to make a directory?
On 02-05-2012 01:45, Minas wrote:
> What is the D way to create a directory?
>
> I can use the C function system("mkdir ...") but it doesn't seem very
> good to me.

It's not in the most obvious of places: 
http://dlang.org/phobos/std_file.html#mkdir

(But then again, an std.directory module would probably be a bit 
overkill...)

>
> Also, is there a way to require the root password of the user when going
> create the directory in a restricted folder (like /usr) AFTER the
> application has started?

No idea, sorry.

>
> Thank you.

-- 
- Alex
May 02, 2012
Re: How to make a directory?
On May 1, 2012 7:49 PM, "Alex Rønne Petersen" <xtzgzorex@gmail.com> wrote:
>>
>> Also, is there a way to require the root password of the user when going
>> create the directory in a restricted folder (like /usr) AFTER the
>> application has started?
>
>
> No idea, sorry.
>
>>
>> Thank you.
>
>
> --
> - Alex

You could execute a system command and change your apps privileges but this
is a bad/risky way to do it.  I would use sudo or gksudo and launch the
command externally so that you don't grant your app root permissions and
then do something stupid.  If those actions are common I would only allow
root to use your app.
May 02, 2012
Re: How to make a directory?
Al 02/05/12 01:45, En/na Minas ha escrit:
[...]
> Also, is there a way to require the root password of the user when going create the directory in a restricted folder (like /usr) AFTER the application has started?

In Linux, files and directories have the "setuid" and "setgid" special flags that allow ordinary users to execute binaries with temporary privileges of binary file owner or group.

i.e., /usr/bin/passwd (owns root, with setuid) modifies /etc/passwd by any user without write permission. /bin/ping (owns root, with setuid) allows any user to send and listen control packages throw net interfaces.

-- 
Jordi Sayol
Top | Discussion index | About this forum | D home