verification on FpChmod Mode usage lazarus / 62-General ---------------------------------------------------------------------- petevick · 2022-04-22 17:07 I've used the following to copy a Linux program file from A to B..... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i CopyFile('test/testprog', 'backup/testprog')....but after it's copied the files Execute permission is False, so I've used FpChmod() to reset it to True thus..... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FpChmod('backup/testprog', S_IRWXU)...and after a bit of trial and error I found the above Mode setting S_IRWXU worked, but is it the right mode to use. I was working on the theory that if it works it's not wrong, but I'm really not sure now. ---------------------------------------------------------------------- dsiders · 2022-04-22 17:32 Quote from: petevick on April 22, 2022, 07:07:28 pmI've used the following to copy a Linux program file from A to B..... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i CopyFile('test/testprog', 'backup/testprog')....but after it's copied the files Execute permission is False, so I've used FpChmod() to reset it to True thus..... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FpChmod('backup/testprog', S_IRWXU)...and after a bit of trial and error I found the above Mode setting S_IRWXU worked, but is it the right mode to use. I was working on the theory that if it works it's not wrong, but I'm really not sure now.  S_IRWXU sets read, write, and execute user permissions... if that's what you're after. S_IRWXG is for group permissions. S_IRWXO is for other permissions. ---------------------------------------------------------------------- Kays · 2022-04-22 19:14 Quote from: petevick on April 22, 2022, 07:07:28 pm[…] I was working on the theory that if it works it's not wrong, but I'm really not sure now.  The “correct way” is to call fpUmask prior copyFile. Note umask(2) needs the permissions you do not want (i. e. a mask), so fpUmask(S_IRWXG or S_IRWXO) would be appropriate to ensure only the creating user has any privileges. You can still request fewer privileges in your file-creating function, but none the current umask “forbid”. Gaining more rights requires a subsequent chmod (you’ve already noticed that). ---------------------------------------------------------------------- petevick · 2022-04-22 19:32 Quote from: Kays on April 22, 2022, 09:14:05 pmQuote from: petevick on April 22, 2022, 07:07:28 pm[…] I was working on the theory that if it works it's not wrong, but I'm really not sure now.  The “correct way” is to call fpUmask prior copyFile. Note umask(2) needs the permissions you do not want (i. e. a mask), so fpUmask(S_IRWXG or S_IRWXO) would be appropriate to ensure only the creating user has any privileges. You can still request fewer privileges in your file-creating function, but none the current umask “forbid”. Gaining more rights requires a subsequent chmod (you’ve already noticed that). Thanks for the reply, but unfortunately I can't get that to work, I tried both S_IRWXG and S_IRWXO and even S_IRWXU, none set the Execute permission to True.  ...hmmm, or do I still need to use FpChmod() as well ---------------------------------------------------------------------- Kays · 2022-04-23 09:14 Quote from: petevick on April 22, 2022, 09:32:33 pmThanks for the reply, but unfortunately I can't get that to work […]Then your program is likely asking for fewer permission. What does an strace ./myProgram show (specifically when the copy is created)? ---------------------------------------------------------------------- petevick · 2022-04-23 09:29 Quote from: Kays on April 23, 2022, 11:14:01 amThen your program is likely asking for fewer permission. What does an strace ./myProgram show (specifically when the copy is created)? Most of the strace output was mouse moving events, but I think this is when the copy is done, to me it looks like garbage  .... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i writev(4, [ {iov_base="\213\4\6\0\26\3@\5\25\3@\5&\0\0\0\0\4\0\0\1\0\0\0\213\36\5\ 0\26\3@\5"..., iov_len=2204}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 2204recvmsg(4, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)recvmsg(4, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)recvmsg(4, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)recvmsg(4, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)recvmsg(4, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)recvmsg(4, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=8, events=POLLIN}], 4, 3515) = 1 ([{fd=4, revents=POLLIN}])recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\5\1@\22\205\353\37 6\0\257\6\0\0D\0@\5\0\0\0\0\250\3\200\2O\1\17\1\20\1\1\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])writev(4, [{iov_base="$\4\1\0&\3\2\0\257\6\0\0", iov_len=12}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 12poll([{fd=4, events=POLLIN}], 1, -1)    = 1 ([{fd=4, revents=POLLIN}])recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\1B\22\0\0\0\0\257\6\0\0\17\316 \3\250\3\200\2\250\3\200\2\20\0\0\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])writev(4, [{iov_base="&\4\2\0\17\316 \3", iov_len=8}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 8poll([{fd=4, events=POLLIN}], 1, -1)    = 1 ([{fd=4, revents=POLLIN}])recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{i ov_base="\1\1C\22\0\0\0\0\257\6\0\0D\0@\5\250\3\200\2P\1- \1\20\0\0\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])writev(4, [{iov_base="&\4\2\0D\0@\5", iov_len=8}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 8poll([{fd=4, events=POLLIN}], 1, -1)    = 1 ([{fd=4, revents=POLLIN}])recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{i ov_base="\1\1D\22\0\0\0\0\257\6\0\0\0\0\0\0\250\3\200\2O\1\17\1\20\0\0 \0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])writev(4, [{iov_base="%\4\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])writev(4, [{iov_base="\2\4\4\0D\0@\5\0@\0\0B\0@\5&\4\2\0\257\6\0\0", iov_len=24}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 24