GetTempFileName in Linux

classic Classic list List threaded Threaded
44 messages Options
123
Reply | Threaded
Open this post in threaded view
|

GetTempFileName in Linux

Leonardo M. Ramé
Hi, if I run this program from command line in Linux, I allways get the same result, "/tmp/TMP00000.tmp". Shouldn't it return a different file name each time it's executed?.

How can I get different file names?

program tempfilename;
uses
  sysutils;
begin
  writeln(GetTempFileName);
end.


Leonardo M. Ramé
http://leonardorame.blogspot.com



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Sven Barth-2
Am 05.10.2010 17:20, schrieb Leonardo M. Ramé:

> Hi, if I run this program from command line in Linux, I allways get the same result, "/tmp/TMP00000.tmp". Shouldn't it return a different file name each time it's executed?.
>
> How can I get different file names?
>
> program tempfilename;
> uses
>    sysutils;
> begin
>    writeln(GetTempFileName);
> end.

Did you delete the file after the run of your program? GetTempFileName
always starts from 0 and checks whether that file already exists. If
not, it returns that name else it continues increasing the index.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Michael Van Canneyt
In reply to this post by Leonardo M. Ramé


On Tue, 5 Oct 2010, Leonardo M. Ramé wrote:

> Hi, if I run this program from command line in Linux, I allways get the same result, "/tmp/TMP00000.tmp". Shouldn't it return a different file name each time it's executed?.
>
> How can I get different file names?

By actually creating the file. GetTempFileName does not create a file, but
does check whether the filename exists.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Jonas Maebe-2

On 05 Oct 2010, at 17:38, Michael Van Canneyt wrote:

> On Tue, 5 Oct 2010, Leonardo M. Ramé wrote:
>
>> Hi, if I run this program from command line in Linux, I allways get the same result, "/tmp/TMP00000.tmp". Shouldn't it return a different file name each time it's executed?.
>> How can I get different file names?
>
> By actually creating the file. GetTempFileName does not create a file, but
> does check whether the filename exists.

What is the use of that? Between the check and creating the file, some other process may already have created it.


Jonas_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

ik-6
In reply to this post by Sven Barth-2
On Tue, Oct 5, 2010 at 17:30, Sven Barth <[hidden email]> wrote:
Am 05.10.2010 17:20, schrieb Leonardo M. Ramé:

Hi, if I run this program from command line in Linux, I allways get the same result, "/tmp/TMP00000.tmp". Shouldn't it return a different file name each time it's executed?.

How can I get different file names?

program tempfilename;
uses
  sysutils;
begin
  writeln(GetTempFileName);
end.

Did you delete the file after the run of your program? GetTempFileName always starts from 0 and checks whether that file already exists. If not, it returns that name else it continues increasing the index.


That's a security risk, because it is very easy to know what will be the file name. It should return random name that does not exists on a random length (that the developer chooses).

Symlink attack: http://www.infosecwriters.com/texts.php?op=display&id=159 for better understanding.
 

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Ido

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Leonardo M. Ramé
Well, I need to create BMP files with unique name, to be sent to lpr, then printed. 

Instead of using GetTempFileName, I'll use a GUID, with CreateGUID, and GUIDToString.

Leonardo M. Ramé
http://leonardorame.blogspot.com

--- On Tue, 10/5/10, ik <[hidden email]> wrote:

From: ik <[hidden email]>
Subject: Re: [fpc-pascal] GetTempFileName in Linux
To: "FPC-Pascal users discussions" <[hidden email]>
Date: Tuesday, October 5, 2010, 2:26 PM

On Tue, Oct 5, 2010 at 17:30, Sven Barth <pascaldragon@...> wrote:
Am 05.10.2010 17:20, schrieb Leonardo M. Ramé:

Hi, if I run this program from command line in Linux, I allways get the same result, "/tmp/TMP00000.tmp". Shouldn't it return a different file name each time it's executed?.

How can I get different file names?

program tempfilename;
uses
  sysutils;
begin
  writeln(GetTempFileName);
end.

Did you delete the file after the run of your program? GetTempFileName always starts from 0 and checks whether that file already exists. If not, it returns that name else it continues increasing the index.


That's a security risk, because it is very easy to know what will be the file name. It should return random name that does not exists on a random length (that the developer chooses).

Symlink attack: http://www.infosecwriters.com/texts.php?op=display&id=159 for better understanding.
 

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Ido

-----Inline Attachment Follows-----

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Sven Barth-2
In reply to this post by Jonas Maebe-2
Am 05.10.2010 17:41, schrieb Jonas Maebe:

>
> On 05 Oct 2010, at 17:38, Michael Van Canneyt wrote:
>
>> On Tue, 5 Oct 2010, Leonardo M. Ramé wrote:
>>
>>> Hi, if I run this program from command line in Linux, I allways get the same result, "/tmp/TMP00000.tmp". Shouldn't it return a different file name each time it's executed?.
>>> How can I get different file names?
>>
>> By actually creating the file. GetTempFileName does not create a file, but
>> does check whether the filename exists.
>
> What is the use of that? Between the check and creating the file, some other process may already have created it.

That might be the reason why Windows is creating the file for you if you
call GetTempFileName... so GetTempFileName in FPC does not expose the
same behavior on non-Windows and Windows.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Sven Barth-2
In reply to this post by ik-6
Am 05.10.2010 18:26, schrieb ik:

> On Tue, Oct 5, 2010 at 17:30, Sven Barth <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Am 05.10.2010 17:20, schrieb Leonardo M. Ramé:
>
>         Hi, if I run this program from command line in Linux, I allways
>         get the same result, "/tmp/TMP00000.tmp". Shouldn't it return a
>         different file name each time it's executed?.
>
>         How can I get different file names?
>
>         program tempfilename;
>         uses
>            sysutils;
>         begin
>            writeln(GetTempFileName);
>         end.
>
>
>     Did you delete the file after the run of your program?
>     GetTempFileName always starts from 0 and checks whether that file
>     already exists. If not, it returns that name else it continues
>     increasing the index.
>
>
>
> That's a security risk, because it is very easy to know what will be the
> file name. It should return random name that does not exists on a random
> length (that the developer chooses).
>
> Symlink attack:
> http://www.infosecwriters.com/texts.php?op=display&id=159
> <http://www.infosecwriters.com/texts.php?op=display&id=159> for better
> understanding.

Windows (or at least ReactOS) seems to use GetTickCount to generate a
random filename:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/file.c?revision=48845&view=markup 
(look for GetTempFilenameW)

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Michael Van Canneyt
In reply to this post by Sven Barth-2


On Wed, 6 Oct 2010, Sven Barth wrote:

> Am 05.10.2010 17:41, schrieb Jonas Maebe:
>>
>> On 05 Oct 2010, at 17:38, Michael Van Canneyt wrote:
>>
>>> On Tue, 5 Oct 2010, Leonardo M. Ramé wrote:
>>>
>>>> Hi, if I run this program from command line in Linux, I allways get the
>>>> same result, "/tmp/TMP00000.tmp". Shouldn't it return a different file
>>>> name each time it's executed?.
>>>> How can I get different file names?
>>>
>>> By actually creating the file. GetTempFileName does not create a file, but
>>> does check whether the filename exists.
>>
>> What is the use of that? Between the check and creating the file, some
>> other process may already have created it.
This is always true on Unix, the only way to make sure is to have the kernel
create the temporary name and file for you. Unix - to my knowledge - does not
have a way to create and lock a file in one atomic operation; There are
always 2 operations involved, and so anything can happen between the 2
calls.

> That might be the reason why Windows is creating the file for you if you call
> GetTempFileName... so GetTempFileName in FPC does not expose the same
> behavior on non-Windows and Windows.

I'm open for some more sophisticated algorithm which does some more checking.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Jonas Maebe-2

On 06 Oct 2010, at 09:41, Michael Van Canneyt wrote:

> This is always true on Unix, the only way to make sure is to have  
> the kernel
> create the temporary name and file for you. Unix - to my knowledge -  
> does not have a way to create and lock a file in one atomic  
> operation; There are
> always 2 operations involved, and so anything can happen between the 2
> calls.

You can at least open a file with O_CREAT|O_EXCL|O_NOFOLLOW to make  
sure that it does not yet exist at the point that you create it (and  
that it's not a symlink either).


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Michael Van Canneyt


On Wed, 6 Oct 2010, Jonas Maebe wrote:

>
> On 06 Oct 2010, at 09:41, Michael Van Canneyt wrote:
>
>> This is always true on Unix, the only way to make sure is to have the
>> kernel
>> create the temporary name and file for you. Unix - to my knowledge - does
>> not have a way to create and lock a file in one atomic operation; There are
>> always 2 operations involved, and so anything can happen between the 2
>> calls.
>
> You can at least open a file with O_CREAT|O_EXCL|O_NOFOLLOW to make sure that
> it does not yet exist at the point that you create it (and that it's not a
> symlink either).

This is correct, but doesn't lock the file, and so it doesn't prevent
someone from 'stealing' the file before the lock is applied.
It's of course a remote possibility.

Personally, I have more problems with windows which actually creates the files
and locks them. It sometimes requires a reboot to release the lock again in
case something happens to the calling process.

That said, I repeat: no problem if someone implements a more secure
algorithm.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Jonas Maebe-2

On 06 Oct 2010, at 11:05, Michael Van Canneyt wrote:

> On Wed, 6 Oct 2010, Jonas Maebe wrote:
>
>> On 06 Oct 2010, at 09:41, Michael Van Canneyt wrote:
>>
>>> This is always true on Unix, the only way to make sure is to have  
>>> the kernel
>>> create the temporary name and file for you. Unix - to my knowledge  
>>> - does not have a way to create and lock a file in one atomic  
>>> operation; There are
>>> always 2 operations involved, and so anything can happen between  
>>> the 2
>>> calls.
>>
>> You can at least open a file with O_CREAT|O_EXCL|O_NOFOLLOW to make  
>> sure that it does not yet exist at the point that you create it  
>> (and that it's not a symlink either).
>
> This is correct, but doesn't lock the file,

Locking is always advisory on Unix, so that doesn't matter anyway.

> and so it doesn't prevent
> someone from 'stealing' the file before the lock is applied.

Nobody else can steal the file once you have created it, because they  
won't be the owner nor have the necessary permissions. That is the  
main security risk and it is solved by this approach. The fact that  
another process running under your login not using O_EXCL could  
overwrite it is not an extra security risk (if you have a rogue  
process running under your login, nothing that you do is safe because  
it can use ptrace to modify any process in any way it sees fit anyway).


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Michael Van Canneyt


On Wed, 6 Oct 2010, Jonas Maebe wrote:

>
> On 06 Oct 2010, at 11:05, Michael Van Canneyt wrote:
>
>> On Wed, 6 Oct 2010, Jonas Maebe wrote:
>>
>>> On 06 Oct 2010, at 09:41, Michael Van Canneyt wrote:
>>>
>>>> This is always true on Unix, the only way to make sure is to have the
>>>> kernel
>>>> create the temporary name and file for you. Unix - to my knowledge - does
>>>> not have a way to create and lock a file in one atomic operation; There
>>>> are
>>>> always 2 operations involved, and so anything can happen between the 2
>>>> calls.
>>>
>>> You can at least open a file with O_CREAT|O_EXCL|O_NOFOLLOW to make sure
>>> that it does not yet exist at the point that you create it (and that it's
>>> not a symlink either).
>>
>> This is correct, but doesn't lock the file,
>
> Locking is always advisory on Unix, so that doesn't matter anyway.
>
>> and so it doesn't prevent
>> someone from 'stealing' the file before the lock is applied.
>
> Nobody else can steal the file once you have created it, because they won't
> be the owner nor have the necessary permissions. That is the main security
> risk and it is solved by this approach. The fact that another process running
> under your login not using O_EXCL could overwrite it is not an extra security
> risk (if you have a rogue process running under your login, nothing that you
> do is safe because it can use ptrace to modify any process in any way it sees
> fit anyway).

And that is why I think the whole point is hugely exaggerated :-)

But it doesn't mean we shouldn't do our best to make it minimally safe.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Jonas Maebe-2

On 06 Oct 2010, at 11:59, Michael Van Canneyt wrote:

> On Wed, 6 Oct 2010, Jonas Maebe wrote:
>
>> Nobody else can steal the file once you have created it, because  
>> they won't be the owner nor have the necessary permissions. That is  
>> the main security risk and it is solved by this approach. The fact  
>> that another process running under your login not using O_EXCL  
>> could overwrite it is not an extra security risk (if you have a  
>> rogue process running under your login, nothing that you do is safe  
>> because it can use ptrace to modify any process in any way it sees  
>> fit anyway).
>
> And that is why I think the whole point is hugely exaggerated :-)

It's not, because currently a process from *another* user can  
trivially intercept your temporary files. If you have a daemon running  
as root, that is a major security concern.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Giuliano Colla-2
In reply to this post by Michael Van Canneyt
Michael Van Canneyt ha scritto:

>
>
> On Wed, 6 Oct 2010, Jonas Maebe wrote:
>
>>
>> On 06 Oct 2010, at 11:05, Michael Van Canneyt wrote:
>>
>>> On Wed, 6 Oct 2010, Jonas Maebe wrote:
>>>
>>>> On 06 Oct 2010, at 09:41, Michael Van Canneyt wrote:
>>>>
>>>>> This is always true on Unix, the only way to make sure is to have
>>>>> the kernel
>>>>> create the temporary name and file for you. Unix - to my knowledge
>>>>> - does not have a way to create and lock a file in one atomic
>>>>> operation; There are
>>>>> always 2 operations involved, and so anything can happen between the 2
>>>>> calls.
>>>>
>>>> You can at least open a file with O_CREAT|O_EXCL|O_NOFOLLOW to make
>>>> sure that it does not yet exist at the point that you create it (and
>>>> that it's not a symlink either).
>>>
>>> This is correct, but doesn't lock the file,
>>
>> Locking is always advisory on Unix, so that doesn't matter anyway.
>>
>>> and so it doesn't prevent
>>> someone from 'stealing' the file before the lock is applied.
>>
>> Nobody else can steal the file once you have created it, because they
>> won't be the owner nor have the necessary permissions. That is the
>> main security risk and it is solved by this approach. The fact that
>> another process running under your login not using O_EXCL could
>> overwrite it is not an extra security risk (if you have a rogue
>> process running under your login, nothing that you do is safe because
>> it can use ptrace to modify any process in any way it sees fit anyway).
>
> And that is why I think the whole point is hugely exaggerated :-)
>
> But it doesn't mean we shouldn't do our best to make it minimally safe.
>
> Michael.
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>

To avoid reinventing the wheel, POSIX provides:

int mkstemp(*char template)

( http://linux.die.net/man/3/mkstemp )

which does exactly what is required, i.e. it creates an unique name and
opens the file for write with O_EXCL flag, and permissions 0600
(starting from glibc 2.0.7, before it was 0666), ensuring the uniqueness
on success.

If libc dependency is not desirable, the same functionality can be
reimplemented in fpc, using libc implementation as a guideline to
maintain consistency in Unix environment.

Giuliano


--
Giuliano Colla

Whenever people agree with me, I always feel I must be wrong (O. Wilde)

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Jonathan-181
In reply to this post by Michael Van Canneyt
On Wed, 6 Oct 2010 09:41:03 +0200 (CEST)
Michael Van Canneyt <[hidden email]> wrote:

> I'm open for some more sophisticated algorithm which does some more checking.
>
> Michael.

Honour one of the temp directory environment variables, I know of TMPDIR, TEMP, TMP. I think it would be best to check them in order and then default to /tmp/.
Create a folder in the temp directory naming it after the user name. E.g /tmp/myusername/
Ensure only the owner can read and write in the folder.
Create a folder in "/tmp/myusername/" using your program name.
Then create your temp file. so you have "/tmp/myusername/programname/tmp01"

You should only need to check for symlinks, hardlinks and read/write rights on the "/tmp/myusername" folder.

What is the cost?
 Two more inodes
 More cpu time
What do you get?
 It hides the file's names
 Good layout
 Easier  to use Tomoyo and Apparmour.



On Wed, 06 Oct 2010 09:40:42 +0200
Sven Barth <[hidden email]> wrote:

>Windows (or at least ReactOS) seems to use GetTickCount to generate a
>random filename:
Do not you use random file names without a subdirectory because you can not use Tomoyo or Apparmour to lock the program down.

I use this trick with Firefox.
From my .bashrc file
 mkdir /tmp/$USER >> /dev/null 2>&1
 chmod u=rwx,g=rwx,o-rwx /tmp/$USER >> /dev/null 2>&1
 export TMPDIR="/tmp/$USER" >> /dev/null 2>&1

#!/bin/sh
mkdir $TMPDIR/firefox/
env TMPDIR=$TMPDIR/firefox /usr/bin/firefox $@

From my Tomoyo profile:
 allow_read/write /tmp/\*/firefox/\*
 allow_rename /tmp/\*/firefox/\* /tmp/\*/firefox/\*
 allow_rename /tmp/\*/firefox/\*.part /home/\*/Downloads/\*
 allow_truncate /tmp/\*/firefox/\*
 allow_unlink /tmp/\*/firefox/\*

Since there is no way to predict what the file name will be, permissions have to be done on a per folder basis, not per file.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Michael Van Canneyt


On Wed, 6 Oct 2010, Jonathan wrote:

> On Wed, 6 Oct 2010 09:41:03 +0200 (CEST)
> Michael Van Canneyt <[hidden email]> wrote:
>
>> I'm open for some more sophisticated algorithm which does some more checking.
>>
>> Michael.
>
> Honour one of the temp directory environment variables, I know of TMPDIR, TEMP, TMP. I think it would be best to check them in order and then default to /tmp/.
> Create a folder in the temp directory naming it after the user name. E.g /tmp/myusername/
> Ensure only the owner can read and write in the folder.
> Create a folder in "/tmp/myusername/" using your program name.
> Then create your temp file. so you have "/tmp/myusername/programname/tmp01"
>
> You should only need to check for symlinks, hardlinks and read/write rights on the "/tmp/myusername" folder.
>
> What is the cost?
> Two more inodes
> More cpu time
> What do you get?
> It hides the file's names
> Good layout
> Easier  to use Tomoyo and Apparmour.

I'm all for it, but I was kind of hoping for an implementation :-)

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Graeme Geldenhuys-2
In reply to this post by Jonathan-181
On 6 October 2010 23:57, Jonathan <[hidden email]> wrote:
> Create a folder in the temp directory naming it after the user name. E.g /tmp/myusername/
> Ensure only the owner can read and write in the folder.
> Create a folder in "/tmp/myusername/" using your program name.
> Then create your temp file. so you have "/tmp/myusername/programname/tmp01"

The norm under my system, Ubuntu Linux 10.04 (and probably all other
Linux systems too), is to use the format "<program>-<user>" as the
temp directory. See the listing of my /tmp/ directory.


-------------------------------
srwxr-xr-x 1 graemeg graemeg      0 2010-10-06 14:47 gedit.graemeg.3293794453
drwx------ 2 graemeg graemeg   4096 2010-09-28 09:19 keyring-tTwy4j
drwx------ 2 graemeg graemeg   4096 2010-10-06 16:29 mc-graemeg
drwx------ 2 root    root      4096 2010-10-01 09:27 mc-root
drwx------ 2 gdm     gdm       4096 2010-09-28 09:19 orbit-gdm
drwx------ 2 graemeg graemeg   4096 2010-10-07 09:07 orbit-graemeg
drwx------ 2 root    root      4096 2010-10-01 09:27 orbit-root
drwx------ 2 graemeg graemeg   4096 2010-09-28 09:19 pulse-6W7jC4ahCwwh
drwx------ 2 gdm     gdm       4096 2010-09-28 09:19 pulse-PKdhtXMmr18n
drwx------ 2 graemeg graemeg   4096 2010-09-28 09:19 ssh-ksaXcs1548
drwxr-xr-x 2 graemeg graemeg   4096 2010-10-07 09:05 TempDUnitFiles
-rw-r--r-- 1 graemeg graemeg 672364 2010-10-06 17:00 TMP00000.log
drwx------ 2 graemeg graemeg   4096 2010-09-28 09:19 virtual-graemeg.pm1Pse
-------------------------------



--
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net:8080/fpgui/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Michael Van Canneyt


On Thu, 7 Oct 2010, Graeme Geldenhuys wrote:

> On 6 October 2010 23:57, Jonathan <[hidden email]> wrote:
>> Create a folder in the temp directory naming it after the user name. E.g /tmp/myusername/
>> Ensure only the owner can read and write in the folder.
>> Create a folder in "/tmp/myusername/" using your program name.
>> Then create your temp file. so you have "/tmp/myusername/programname/tmp01"
>
> The norm under my system, Ubuntu Linux 10.04 (and probably all other
> Linux systems too),

Aahhh.. Norms. Right. like all config files should go in ~/.config/, as
proposed 5 years ago, because ~/.program/ is "not the norm" (dumping a
successful 20-year old practise for no apparent good reason).

Meanwhile I'm still waiting for the first non-fpc app to write it's config
files in that directory (using Kubuntu, BTW). All other apps I use still
happily write in ~/.program/

Same on Microsoft: 'every program must be installed under C:\program files\'.
Oh yes. Meanwhile more and more programs write NOT under C:\program files\
because it is more and more a pain in the *** with each new release of Windows.

So: Norms ? Thank you, but I'll pass on that and implement what I perceive as
simple and correct :-)

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetTempFileName in Linux

Graeme Geldenhuys-2
On 7 October 2010 10:40, Michael Van Canneyt <[hidden email]> wrote:
>
> Meanwhile I'm still waiting for the first non-fpc app to write it's config
> files in that directory (using Kubuntu, BTW). All other apps I use still
> happily write in ~/.program/

Well, then here it is.... In my ~/.config/ I have the following
non-FPC projects config files

* enchant
* f-spot
* google-chrome
* indicators
* helix
* gnome-disk-utility
* gnome-session
* gnome-mplayer
* gtk-2.0
* softwarecenter
* totem
* vlc
* ubuntuone
* WebIssues
* ...Qt too... there is a Trolltech.conf file, but not in a separate directory


All non-FPC apps Michael!  So the word is spreading. ;-)


> So: Norms ? Thank you, but I'll pass on that and implement what I perceive
> as
> simple and correct :-)

I don't perceive to know all the "unix/linux standards" or "unix
norms"... I do know Midnight Commander (console file manager) is
probably as old as Linux, and it too creates /tmp/mc-graemeg/
directory for any temp files it creates. That's a non-FPC app too. So
I really don't understand your issue with what I said... maybe "norm"
was not the correct word to use then?

PS:
I didn't get the /tmp/<program>-<user>/ information from
freedesktops.org or any other website for that matter, I simply saw it
created by a few linux applications I use, so thought I would mention
it, as it is similar to what Jonathan suggested.


--
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net:8080/fpgui/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
123