[Gambas-user] how to start a file?
Doriano Blengino
doriano.blengino at ...1909...
Sun Sep 27 11:03:27 CEST 2009
Robert JUHASZ ha scritto:
> Hello,
>
> I'm very happy with this solution and was perfect as long as I used my
> program myself.
> Now I wanna put it in a common folder on the server and for storing the
> files I'll use a folder. To avoid the direct access of this folder, I'll
> make it protected.
>
> The question now is how can I handle this kind of folder from Gambas. I
> don't wish to deal with the rights of teh folder. The idea is to give a read
> and write password to the folder and use the password from Gambas according
> to the user rights in Gambas.
>
> - the files will be displayed by a file view control. Is there any place of
> this control to enter (from code) the reading / writing password of the
> folder used by the control?
>
> - or, when using the Desktop.Open function, can I specify if I open the file
> for read only?
>
Complicated matter... I don't understand well, but I will try to add
some information you may miss.
First of all, at the file system level there could be everything you
need. A file can be made not accessible, or readonly, or fully writable,
to every single user of the computer. This is not so simple, however,
because when two different users must share some privileges, you must
use groups and things get messy. Even so, protecting a folder has
different effects than proteting files. For example, if you
write-protect a folder, you only assure that in that folder no files
will be added or deleted, but single files will remain writeable. I bet
this is not what you intended. On the other hand, if a file (not its
folder) is write protected to a user, then that user will have no way to
modify the file - every program will open that file in read-only mode.
To prevent the file from being deleted, its folder must be protected,
not the file itself.
Finally, to use such system, every user must login in the system using
its own identifier; if you have only one copy of your program running,
with different users alternating if front of it, then you should have
your gambas program change user ID (there is a system call for this, but
gambas don't seem to implement it). However, you can take advantage of
/bin/sudo, which lets you impersonate other users. The system is
configurable and not difficult to understand (see the manual page).
About FileView control, it has no property for specifying a username,
but you can use a textbox aside and ask the user to write its username.
Desktop.Open, or any other "high level" shell function, can not "open a
file read-only"; it is the final program that must be instructed to work
in read-only, be it openoffice, or a CAD, or anything else. Perhaps not
all the program can be instructed to do so. It is possible, however, to
protect the file before launching the application, and remove the
protection afterward, Or the file can be copied elsewhere and then
opened, alerting the user that modifications will be lost.
I don't know what you are trying to do, and what your final system
should look (one computer? many? Several system-level users? Just one?)
but the final solutions could be to manage the access rights inside the
program - your program asks for credentials, and then decides what to
show, what to open read-only and what to permit to be modified or deleted.
There are add-ons for Linux which permit, at the filesystem level, to
use ACLs (access control list). This way you can more easily grant
permissions to single users without getting crazy with users and groups.
Or you can make several folders with different permissions (one
writeable to anyone, another only readeable to everyone, and so on).
Hope I pointed out some useful idea,
regards,
--
Doriano Blengino
"Listen twice before you speak.
This is why we have two ears, but only one mouth."
More information about the User
mailing list