pconde
19th March 2009, 08:41
Hi,

We are working with UNIX (sun OS 5.9) and baanIV SP5.
I used file.mv to move files between an initial location and a back-up location.
The two libraries are with permissions drwxrwxrwx owner and group is bsp.
The files created have the following permissions -rw-r----- userA group_bsp.

if I use userB, I can at unix level execute the command
"mv /pathA/fileA /pathB/filea" The file is then moved in pathB with permissions, owner and group same as original "-rw-r----- userA group_bsp"

In the Baan script, executed with same userB, the Baan command file.mv fails (return code = -1 and e =13 this identify a permission problem).:mad:

If I execute in the Baan script the shell command
shell("mv patha/filea /pathb/filea" SHELL_BACKGROUND) if works succesfully.

Seems that file.mv is more restrictive than the unix command "mv" :D

Any idea why this occurs?

günther
19th March 2009, 09:20
I would like to tell you a bit move about the unix mv command. First question: Are the files or directories on the same filesystem?
* If no, then the file is copied first, and then the original is removed. Example: as root, create a file test in /var; permission 666.
Then try mv /var/test /tmp; you will get a file /tmp/test, and the error message "mv: /var/test: cannot unlink: Permission denied",
because /var is not writable by normal users.
* If yes, then it's what the we normally expect.

I don't know exactly how file.mv() is implemented, but I think that it's not a shell("mv ...") mostly because of the huge overhead of shell(). So I made a simple test program:


function test.file.mv()
{
long ts, te, rc

| just a huge file
file.cp("/stand/vmunix", "/tmp/vmunix")

ts = time.num()
rc = file.mv("/tmp/vmunix", "/tmp/vmunix.new")
te = time.num()

message("rc=%d time=%d", rc, te-ts)
}


On my system, this "move" takes 5 seconds, so i guess its a copy/unlink!

And last but not least, whenever a file gets created, check the umask settings of that user, e.g umask 7 gives rw-rw----, but umask 0 gives rw-rw-rw- and so on.

Günther

pconde
19th March 2009, 10:05
Hi,

Both libraries are on the same file system.
I had already looked to the umask of the userA (who created the file, umask = 022) but the system administrator doesn't want to change it and I must work with this.

I have a work around using the shell command but for portability reasons I use file.mv or any file.* command and I try to avoid shell commands.

My first tests didn't give any problem with file.mv, ( i used the same user) but integration testing showed this difference.:D

Hope this can help somebody.

Philippe

NPRao
19th March 2009, 21:26
I had already looked to the umask of the userA (who created the file, umask = 022) but the system administrator doesn't want to change it and I must work with this.
Philippe,

Refer to the threads, they might help you out -

file permission on UNIX (http://www.baanboard.com/baanboard/showthread.php?t=10295&highlight=bmask)

BaaN/Unix file security (http://www.baanboard.com/baanboard/showthread.php?t=8549&highlight=bmask)