• Print

Author Topic: qb64 for linux , file permissions  (Read 267 times)

LINUXQB64gltester

  • Full Member
  • ***
  • Posts: 240
    • Anyone that likes Art
qb64 for linux , file permissions
« on: February 22, 2013, 05:51:14 AM »
Hello everyone,
 Last night, experimenting with Terry Richies newest game, :
Mine Sweeper, 
http://www.qb64.net/forum/index.php?topic=10729.0
 I stumbled on to a small problem, that I had had trouble with before, on various programs, but never occured to me what was going on.
 It is a issue of file permissions, in this case, when I tried to select the expert or intermidiate mode, on the game, I got a invalid handle error, line 972 ( not sure if it was exactly that line,but that is not important),  when I checked, the line, it was calling for the file, "minesweeper.sav",  so I checked, the file was there, in the folder, and spelled corectly,..but still,"invalid handle" or, "can not open the file",... I was baffled,  then it finally entered my thick skull,...
 I checked the file permissions, ahh ahh !eureka!, the permissions were set, as root only, and read only,..I changed the permissions so as to allow "others", acesss, including write,read,etc.
 The program then ran completely, and was able to access the file, ""minesweeper.sav", and edit the data needed, to make that option work.
 I suspect this is the same reason, on some other programs, that include, or call for library, or .bi files,  IE: http://www.qb64.net/forum/index.php?topic=10677.msg89529#msg89529
Quote
if you're using LINUX, does the names match ExAcTlY?  Capitalization DOES matter.   If the file is ZLib.BI, 
   So not only the spelling, but the file permissions, can cause this,..
 Of course, if one is running qb64, as root then the permissions should not matter, but if they are getting a invalid handle, or file not found error, and the is there,and the filename is spelled right, then, the next thing would be to check the permissions.
 Ok well I hope this helps , others, and makes sense, I am not always to good at explaining things,...
For off topic discussions :
Non-QB64 Related Discussion Forum
Also
My Experimenting Forum
"QB64 has a great future!"

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: qb64 for linux , file permissions
« Reply #1 on: February 22, 2013, 05:55:26 AM »
Hi all,
    Handy thing to know Garry. How exactly do you go about changing the permissions. I mean the method that you used , if you could detail the steps for others like me that dont know. Thanks.
OlDosLover.

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: qb64 for linux , file permissions
« Reply #2 on: February 22, 2013, 06:21:40 AM »
Very interesting find.
Something old... Something new... Something borrowed... Something blue...

LINUXQB64gltester

  • Full Member
  • ***
  • Posts: 240
    • Anyone that likes Art
Re: qb64 for linux , file permissions
« Reply #3 on: February 22, 2013, 06:23:23 AM »
Edited:
Quote
Very interesting find. 
thanks, yes indeed, this will help me a lot, I am sure, it was the cause of a lot of confusion,
 when every thing appeared to be correct, and there.

I am late for work, but, if you highlight,(select ) the file, right click, at the bottom you would see "properties",  select that,  it will show, properties, and a button for permissions,
 if you select "Root Actions" instead of properties, at the bottom, there is a option to "change permissions",  this applys to linux mint 13,
 This weekend, I can add some screen shot and explain better, or chance, Matt will give more details , too,.. sorry to be so brief right now, got to run, they are "yelling at me" now!,...
 
For off topic discussions :
Non-QB64 Related Discussion Forum
Also
My Experimenting Forum
"QB64 has a great future!"

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: qb64 for linux , file permissions
« Reply #4 on: February 22, 2013, 04:40:50 PM »
From your new name, I assume that this is a Linus problem as Windows XP has no such file permissions. It wasn't Read Only either. XP does warn me when I open the BAS file in QB64 that it was downloaded from the internet. I always forget to uncheck the box in the warning, but after that it is normally all uphill.

QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

DSMan195276

  • Hero Member
  • *****
  • Posts: 1978
  • Yes
    • Email
Re: qb64 for linux , file permissions
« Reply #5 on: February 22, 2013, 05:38:23 PM »
Strange. ZIP doesn't store file permissions (That's the reason why if make an archive for Linux, you do it in .tar.gz format which does preserve permissions). And, NTFS does has file permissions, it just might not be as obvious because Windows tends to hide them a bit more the Linux does. Windows users really won't run into permissions issues unless they want to copy files over from another user on that computer or want to put something into one of the system folders like Program Files or 'Windows'. And of course, if you're an admin user I don't think file permissions for other users apply to you.

Because ZIP's don't store file permissions, the permissions they do get are the default permissions (553 I think). Those numbers are a bit field, but basically 5 means read-write, 3 means read-only. There are three numbers that represent the owner, group, and then everyone else. So in this case, the owner has the permissions 5 (read and write), anybody in the same group as the file as the permissions 5 (read and write) and everybody else on the system has the permissions 3 (read only). Only the owner or the root user can modify file permissions. *** Any file created by the user (Or by a program being run as that user) will create files with these permissions, which should lead to no permissions problems what-so-ever ***

The only way the owner could be root (Which is what happened here) is if the program that created the file that was causing the error was running as the root user. I couldn't say why that happened, only Garry could know that really. Recent Linux systems (Recent being maybe 5 years or so, probably more) don't allow direct access to the root user any more, the only way to get access is via the 'sudo' command, or it's graphical versions 'gksu', etc. They all prompt for your user password before giving you root access, so if a program is being run this way it should be fairly obvious.

You can change a files permissions via the command line if you use the chmod command (You can send it one of those number triplets like '755' or the one I had above, or you can send it +w, +r, -r, etc. to specifically modify read-write) or most Linux's will allow you to do it from the file manager by just right-clicking and going to properties as Garry said.

It's useful stuff to know if it does cause a problem, but really the only times you run into it is if you try to read stuff outputted from a system program and you didn't use sudo to first give yourself access.

Matt
"Cast your cares on the Lord and he will sustain you; he will never let the righteous be shaken" -- Psalm 55:22
QB64 Linux Installer

LINUXQB64gltester

  • Full Member
  • ***
  • Posts: 240
    • Anyone that likes Art
Re: qb64 for linux , file permissions
« Reply #6 on: February 22, 2013, 06:20:06 PM »
Yes, it is , a Linux, "problem", not so much of a problem, now that I (we) are aware of it, and actually if qb64 is being run  by "root", it probabley wouldn't occur, however, it is not recomended to do things that way, logged in as "root",...
 Root is the default user name, for, complete, or total adminstrative privlidges, when logged in as root, one can do anything they want, or need to. Which is what is recommended, only using/or logging in as root, if and when you need to, and if you know what you are doing,  when logged in as root, one can "crash" or wreck the system, It also is one reason viruses can not function, or get very far in Linux,very easily,..but back to how this relates to qb64 ( sorry ),
 For example, with the program/game Terry, just recently released, it uses a file, "minesweeper.sav",   it is a configuration file,  and says "do not alter this file".
Code: [Select]
  ----------------------------------------
 QB64 Minesweeper configuration/save file
 ----------------------------------------
 ** DO NOT ALTER **
  LEVEL - 1-Beginner, 2-Intermediate, 3-Expert, 4-Custom
 3
 Game cell width - 9-Beginner, 16-Intermediate, 30-Expert, 9to30-Custom
 30
 Game cell height - 9-Beginner, 16-Intermediate, 16-Expert, 9to24-Custom
 16
 Number of mines - 10-Beginner, 40-Intermediate, 99-Expert, 10to90%-Custom
 99
 Sound
 -1
 High scores
 999
Anonymous
999
Anonymous
999
Anonymous
 
The permissions, were by default, "root" is the "owner",  "others" , simpley had no access to it, not even read only,..
 Below is the code where it calls for minesweeper.sav
Code: [Select]
SHARED Game AS GAME '  need access to game options

OPEN "minesweeper.sav" FOR OUTPUT AS #1 ' (my comment)The error said line 945, this line945
 ' open save file for output (Terry included this comment)
PRINT #1, " ----------------------------------------" '                        create the save file
PRINT #1, " QB64 Minesweeper configuration/save file"   
PRINT #1, " ----------------------------------------"

Ok, my first thoughts were that minesweeper.sav, might not be there, or was not spelled correctly, when I saw that it was there, and the spelling was correct, I was baffled "why,can't it find or open it?",.. then it occured to me to check the permissions, and it was clear, when I saw, only root, had access.
  So now , we know, when invalid handles, or can not find, or open a file, occur, to check this,..in a way, I should have figured this sooner, but it never occured to me before.
 Often, when I have installed scripts, such as SMF forum software, or PHPbp, to a web site, they tell you, you need to make sure the file permissions are set correctly, and usually specificly which ones,  this is because unix is the same, and most web host servers, are using unix,...
 In a nut shell, for those that are using qb64 for linux, and if and when they get "invalid handle","file not found" or "unable to open", first check the source,and compare the spelling, (upper and lower case,especially), but if that is ok, then also check the file permissions.
Quote from: OlDosLover on February 22, 2013, 05:55:26 AM
Hi all,
    Handy thing to know Garry. How exactly do you go about changing the permissions. I mean the method that you used , if you could detail the steps for others like me that dont know. Thanks.
OlDosLover.

Basicly as I said, in my other post, Matt would be a better person to go into more details on that,  there are some tutorials, for linux on this, but I don't have the links handy, also, being that  it is just a Linux issue, when I get the chance, I will post more on that, in a more appropiate
 place, ( I wish I knew how to spell better  ???)....
 I am glad , now that I know this, because I suspect that this is what the problem is on several other "projects" , that I had not been able to get running, now I can check them, 
 I sure like the way Terry remarks his code, even though he had not written it ,intended for, qb64 GL, nor Linux, his remarks make it a lot easier to follow the code, and figure what needs to be checked, or changed, in this case, it is no fault of the code, nor  qb64 GL, just Linux, being so picky about "file permissions", etc.
from Garry
 P.S . I see Matt posted while writing this,
Quote
It's useful stuff to know if it does cause a problem, but really the only times you run into it is if you try to read stuff outputted from a system program and you didn't use sudo to first give yourself access. 
Yea, I think so to, it is pretty unusual, most qb64 programs, compile and run just fine, fisrt try,..etc...
Edited:
Quote
The only way the owner could be root (Which is what happened here) is if the program that created the file that was causing the error was running as the root user. I couldn't say why that happened, only Garry could know that really.
   Yea, ok that makes sense,and I should fix that, at this point, when I want to run qb64, I have to start it form the terminal ,as root,..
 That has been annoying me for awhile now, and I need to change it, thanks , Matt,
For off topic discussions :
Non-QB64 Related Discussion Forum
Also
My Experimenting Forum
"QB64 has a great future!"

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: qb64 for linux , file permissions
« Reply #7 on: February 22, 2013, 06:28:40 PM »
WTH! Garry is a new user and with Linus you really need to be an expert or clannish...  ;)

Did you really have to say all of that just to make Linus more understandable? It seemed like even you were a bit confused Matt! New users make mistakes! Apparently Linus hasn't learned that yet!

One thing about M$, at least they think their users are STUPID. Always ASSUME the worst and cheer when they never get there! M$ learned it the hard way!  ;D
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

LINUXQB64gltester

  • Full Member
  • ***
  • Posts: 240
    • Anyone that likes Art
Re: qb64 for linux , file permissions
« Reply #8 on: February 22, 2013, 06:47:45 PM »
Well just speaking for myself, it is kind of hard to explain, and the after all the explaining, it dose even seem more confusing,, and the same when I try to read a tutorial or following instructions, but for some odd reason, most of the time, ....hmmm, never mind, it is too confuseing to try to explain, but, actually it is very logical and simple, at least with linux, for me,....for me windows was even more confusing,..so I was really lost, now, with Linux, I am not "lost" , just "floundering around in the dark" so to speak, but I know where I am, I think ???
 
For off topic discussions :
Non-QB64 Related Discussion Forum
Also
My Experimenting Forum
"QB64 has a great future!"

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: qb64 for linux , file permissions
« Reply #9 on: February 22, 2013, 07:55:21 PM »
I didn't say Dannish! I said clannish...  ;)

I'm old enough to remember when computers came with books, although I seldom read them.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: qb64 for linux , file permissions
« Reply #10 on: February 22, 2013, 09:29:10 PM »
Hi all,
    Linux is not that different than Windows in this file permissions experience. Being an old DOS man i fully understand the Win equivalents. These Win equivalents are
S - system
H - hidden
R - Read Only
A - Archive
    One would use the attrib command to change these qualities of a dos file. You would use {+} to make them that way and {-} to remove those qualities. There are places on Windows that you wont have access to like "System Volume Information" that when read the disk in linus you can see inside this folder. Its almost impossible to change the attribute on this folder in Windows. Windows uses the SYSTEM attribute to keep most queries out. What Garry is describing is the Linus equivalent. Where Linus differes is that it will allow the user to acces and change these hidden and system files and folders. Some malware on Windows will set itself up this way to prevent the user from removing it.
OlDosLover.

DSMan195276

  • Hero Member
  • *****
  • Posts: 1978
  • Yes
    • Email
Re: qb64 for linux , file permissions
« Reply #11 on: February 22, 2013, 11:35:41 PM »
That's not 100% true actually, in regards to how Linux does it. Windows and Linux differ in that Linux has owners and groups. Meaning you can set more specific settings depending on who the user is or if they are in a specific group (using this you can make different accounts have access to different parts of the system -- More importantly you can have some parts of the system that some users can't read or write, even if they can see the file in a directory listing). NTFS may offer some support for this though (What you're talking about was FAT, which had less settings then NTFS does), specifically I think NTFS supports having owners over files where FAT does not.

Most of that is irrelevant to normal Linux users though, I'd argue that most normal Ubuntu and Mint users won't ever run into a file permission error through basic use, simply because that requires having a file who's permissions were set by root, and that requires a program elevates itself to root access. When that happens the user will be told what process is doing this and be asked for their password -- This is fairly uncommon so it would easily tip-off normal users.

Matt
"Cast your cares on the Lord and he will sustain you; he will never let the righteous be shaken" -- Psalm 55:22
QB64 Linux Installer

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: qb64 for linux , file permissions
« Reply #12 on: February 22, 2013, 11:39:24 PM »
Hi all,
    Well this would be a great topic to create a tut out of for the community's greater benefit. Hint Hint!
OlDosLover.

DSMan195276

  • Hero Member
  • *****
  • Posts: 1978
  • Yes
    • Email
Re: qb64 for linux , file permissions
« Reply #13 on: February 22, 2013, 11:47:02 PM »
Quote from: OlDosLover on February 22, 2013, 11:39:24 PM
Hi all,
    Well this would be a great topic to create a tut out of for the community's greater benefit. Hint Hint!
OlDosLover.

I'm not sure the Linux File-system is the idea for the tut section though ;)

Matt
"Cast your cares on the Lord and he will sustain you; he will never let the righteous be shaken" -- Psalm 55:22
QB64 Linux Installer

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: qb64 for linux , file permissions
« Reply #14 on: February 22, 2013, 11:59:51 PM »
Hi all,
    Strictly speaking you are probably right. At least one person has come across this as a problem so to some extent it is relevant. Perhaps if this was added as part of a "How to install QB64 on Linus" then it would be appropriate and relevant. Im willing to do a tut on installing Linux (to use and run QB64 on) for Linux Mint13 ,dual boot with XP or Seven. Included in this would be the actual QB64 installation and we could append it to the end of that as a possible warning problem. What do you think?
OlDosLover.

  • Print