Page 1 of 1

Linux chmod_()

Posted: Fri Nov 14, 2014 5:15 am
by Opcode
How would I properly use the Linux chmod_() function. I tried once and it completely destroyed my Linux install. :shock:

Code: Select all

chmod_("/etc/cron.daily/fstrim", 0755)

Re: Linux chmod_()

Posted: Fri Nov 14, 2014 8:47 am
by auser
0755 is wrong. It would be 493 in that case. You could use strtol() to get your value:

Code: Select all

chmod_("/etc/cron.daily/fstrim",strtol_("0755",0,8))

Re: Linux chmod_()

Posted: Fri Nov 14, 2014 10:04 am
by Opcode
auser wrote:0755 is wrong. It would be 493 in that case. You could use strtol() to get your value:

Code: Select all

chmod_("/etc/cron.daily/fstrim",strtol_("0755",0,8))
I just wanted to be sure of the parameters, seems like chmod_() is quite a fatal function if not used properly.

Re: Linux chmod_()

Posted: Tue Nov 18, 2014 7:08 am
by Opcode
auser wrote:0755 is wrong. It would be 493 in that case. You could use strtol() to get your value:

Code: Select all

chmod_("/etc/cron.daily/fstrim",strtol_("0755",0,8))

Code: Select all

strtol_("0755", 0, 8)
Always returns 0. I tried chmod once again and like last time it bricked my Ubuntu install (had to reinstall, again...).

Re: Linux chmod_()

Posted: Fri Dec 12, 2014 10:15 am
by Opcode
Opcode wrote:

Code: Select all

strtol_("0755", 0, 8)
Always returns 0. I tried chmod once again and like last time it bricked my Ubuntu install (had to reinstall, again...).
I think strtol() and strtoul() are both bugged. Both with normal and su privileges return 0 on Ubuntu 14.04.1 LTS.

Re: Linux chmod_()

Posted: Fri Dec 12, 2014 11:45 am
by luis
Opcode wrote:How would I properly use the Linux chmod_() function. I tried once and it completely destroyed my Linux install. :shock:
...
I tried chmod once again and like last time it bricked my Ubuntu install (had to reinstall, again...)
If you think some code to test can be risky, consider using a virtual machine. At the touch of a button you can restore its previous state without reinstalling.

On a real OS, often another terminal already open with a root account or a sudo it's enough to repair most of the damage one can usually do.

In case that fails, it's a good idea to have a complete image made before. Restoring an image is quicker and less tedious than reinstalling the OS, configuring it , updating it and finally reinstalling all the required programs.

Opcode wrote: I think strtol() and strtoul() are both bugged. Both with normal and su privileges return 0 on Ubuntu 14.04.1 LTS.
Two of the most simple and widely used C library functions bugged.... do you think is likely ?

Or are you compiling with Unicode enabled ?

Code: Select all

long int strtol(const char *nptr, char **endptr, int base);
If that is the problem, you could try to override the PB import, or compile in ascii.

Code: Select all

ImportC ""
 strtol_(nptr.p-utf8, *endptr, base) As "strtol"
EndImport

Code: Select all

Debug  strtol_("0755", 0, 8)  ; 0 in unicode

Debug  strtol_("0755", 0, 8)  ; 493 in unicode with the fixed import
I hope when PB will drop ascii mode all the Linux imports will be fixed.

Re: Linux chmod_()

Posted: Tue Dec 30, 2014 9:26 pm
by luis
Were you able to check about this ? Was it due to unicode or something else ?
luis wrote:Two of the most simple and widely used C library functions bugged.... do you think is likely ?
Or are you compiling with Unicode enabled ?

EDIT: Well, you didn't answer to my question about Unicode, but it's nice to talk to myself. At least it is talking to someone I like. :wink: