Voila j'ai besoin de créer un fichier et ceux de manière unique. J'utilise
donc la fonction mkstemp qui me retourne le file descriptor du fichier ainsi
crée. Je me demandais si il y avais moyen de récupérer le nom du fichier ?
J'avais pensé à la fonction fstat mais je ne récupère que les inodes.
--
Arno - Pour le mail : http://cerbermail.com/?P5oJnDlxNt
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Laurent Le Boterve
"Arno" a écrit dans le message de news:bl1n7l$tdk$
Salut,
Voila j'ai besoin de créer un fichier et ceux de manière unique. J'utilise donc la fonction mkstemp qui me retourne le file descriptor du fichier ainsi
crée. Je me demandais si il y avais moyen de récupérer le nom du fichier ? J'avais pensé à la fonction fstat mais je ne récupère que les inodes.
-- Arno - Pour le mail : http://cerbermail.com/?P5oJnDlxNt
Si le nom est important, tu peux utiliser mktemp() qui te retourne un nom
unique pour faire ensuite un creat et un open.
"Arno" <arno@nospam.com.invalid> a écrit dans le message de
news:bl1n7l$tdk$1@news6.isdnet.net...
Salut,
Voila j'ai besoin de créer un fichier et ceux de manière unique. J'utilise
donc la fonction mkstemp qui me retourne le file descriptor du fichier
ainsi
crée. Je me demandais si il y avais moyen de récupérer le nom du fichier ?
J'avais pensé à la fonction fstat mais je ne récupère que les inodes.
--
Arno - Pour le mail : http://cerbermail.com/?P5oJnDlxNt
Si le nom est important, tu peux utiliser mktemp() qui te retourne un nom
"Arno" a écrit dans le message de news:bl1n7l$tdk$
Salut,
Voila j'ai besoin de créer un fichier et ceux de manière unique. J'utilise donc la fonction mkstemp qui me retourne le file descriptor du fichier ainsi
crée. Je me demandais si il y avais moyen de récupérer le nom du fichier ? J'avais pensé à la fonction fstat mais je ne récupère que les inodes.
-- Arno - Pour le mail : http://cerbermail.com/?P5oJnDlxNt
Si le nom est important, tu peux utiliser mktemp() qui te retourne un nom
unique pour faire ensuite un creat et un open.
Stephane CHAZELAS
Le Fri, 26 Sep 2003 17:50:17 +0200, Arno écrivait :
Voila j'ai besoin de créer un fichier et ceux de manière unique. J'utilise donc la fonction mkstemp qui me retourne le file descriptor du fichier ainsi crée. Je me demandais si il y avais moyen de récupérer le nom du fichier ? J'avais pensé à la fonction fstat mais je ne récupère que les inodes.
Le nom du fichier est dans le template que tu as fourni et que mkstemp a modifié.
Le Fri, 26 Sep 2003 17:50:17 +0200, Arno <arno@nospam.com.invalid> écrivait :
Voila j'ai besoin de créer un fichier et ceux de manière unique. J'utilise
donc la fonction mkstemp qui me retourne le file descriptor du fichier ainsi
crée. Je me demandais si il y avais moyen de récupérer le nom du fichier ?
J'avais pensé à la fonction fstat mais je ne récupère que les inodes.
Le nom du fichier est dans le template que tu as fourni et que
mkstemp a modifié.
Le Fri, 26 Sep 2003 17:50:17 +0200, Arno écrivait :
Voila j'ai besoin de créer un fichier et ceux de manière unique. J'utilise donc la fonction mkstemp qui me retourne le file descriptor du fichier ainsi crée. Je me demandais si il y avais moyen de récupérer le nom du fichier ? J'avais pensé à la fonction fstat mais je ne récupère que les inodes.
Le nom du fichier est dans le template que tu as fourni et que mkstemp a modifié.
Si le nom est important, tu peux utiliser mktemp() qui te retourne un nom unique pour faire ensuite un creat et un open.
Dans tout bon man, il est indiqué la chose suivante pour mktemp :
FreeBSD 4.8 :
BUGS This family of functions produces filenames which can be guessed, though the risk is minimized when large numbers of `Xs' are used to increase the number of possible temporary filenames. This makes the race in mktemp(), between testing for a file's existence (in the mktemp() function call) and opening it for use (later in the user application) particularly dan- gerous from a security perspective. Whenever it is possible, mkstemp() should be used instead, since it does not have the race condition. If mkstemp() cannot be used, the filename created by mktemp() should be cre- ated using the O_EXCL flag to open(2) and the return status of the call should be tested for failure. This will ensure that the program does not continue blindly in the event that an attacker has already created the file with the intention of manipulating or reading its contents.
Linux :
BUGS Never use mktemp(). Some implementations follow BSD 4.3 and replace XXXXXX by the current process id and a single letter, so that at most 26 different names can be returned. Since on the one hand the names are easy to guess, and on the other hand there is a race between test- ing whether the name exists and opening the file, every use of mktemp() is a security risk. The race is avoided by mkstemp(3).
-- DINH V. Hoa,
"je savais que c'était un fan de tunning et de techno mais quand même" -- sunZ
Si le nom est important, tu peux utiliser mktemp() qui te retourne un nom
unique pour faire ensuite un creat et un open.
Dans tout bon man, il est indiqué la chose suivante pour mktemp :
FreeBSD 4.8 :
BUGS
This family of functions produces filenames which can be guessed, though
the risk is minimized when large numbers of `Xs' are used to increase the
number of possible temporary filenames. This makes the race in mktemp(),
between testing for a file's existence (in the mktemp() function call)
and opening it for use (later in the user application) particularly dan-
gerous from a security perspective. Whenever it is possible, mkstemp()
should be used instead, since it does not have the race condition. If
mkstemp() cannot be used, the filename created by mktemp() should be cre-
ated using the O_EXCL flag to open(2) and the return status of the call
should be tested for failure. This will ensure that the program does not
continue blindly in the event that an attacker has already created the
file with the intention of manipulating or reading its contents.
Linux :
BUGS
Never use mktemp(). Some implementations follow BSD 4.3 and replace
XXXXXX by the current process id and a single letter, so that at most
26 different names can be returned. Since on the one hand the names
are easy to guess, and on the other hand there is a race between test-
ing whether the name exists and opening the file, every use of mktemp()
is a security risk. The race is avoided by mkstemp(3).
--
DINH V. Hoa,
"je savais que c'était un fan de tunning et de techno mais quand même" -- sunZ
Si le nom est important, tu peux utiliser mktemp() qui te retourne un nom unique pour faire ensuite un creat et un open.
Dans tout bon man, il est indiqué la chose suivante pour mktemp :
FreeBSD 4.8 :
BUGS This family of functions produces filenames which can be guessed, though the risk is minimized when large numbers of `Xs' are used to increase the number of possible temporary filenames. This makes the race in mktemp(), between testing for a file's existence (in the mktemp() function call) and opening it for use (later in the user application) particularly dan- gerous from a security perspective. Whenever it is possible, mkstemp() should be used instead, since it does not have the race condition. If mkstemp() cannot be used, the filename created by mktemp() should be cre- ated using the O_EXCL flag to open(2) and the return status of the call should be tested for failure. This will ensure that the program does not continue blindly in the event that an attacker has already created the file with the intention of manipulating or reading its contents.
Linux :
BUGS Never use mktemp(). Some implementations follow BSD 4.3 and replace XXXXXX by the current process id and a single letter, so that at most 26 different names can be returned. Since on the one hand the names are easy to guess, and on the other hand there is a race between test- ing whether the name exists and opening the file, every use of mktemp() is a security risk. The race is avoided by mkstemp(3).
-- DINH V. Hoa,
"je savais que c'était un fan de tunning et de techno mais quand même" -- sunZ