Re: [Vala] GIO run as root Fail
- From: Edwin De La Cruz <edwinspire gmail com>
- To: Al Thomas <astavale yahoo co uk>
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] GIO run as root Fail
- Date: Fri, 18 Aug 2017 10:37:30 -0500
int main () {
// A reference to our file
var file = File.new_for_path ("ftp://ftp.gnu.org/");
if (!file.query_exists ()) {
stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
return 1;
}
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ());
string line;
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
stdout.printf ("%s\n", line);
}
} catch (Error e) {
error ("%s", e.message);
}
return 0;
}
I am trying something simpler just with the example that is in the
Wiki, the only thing that does is to list the files in the FTP.
But I get the same result when I run it as root: "Operation not supported".
When I run it as a normal user I have no problem.
Something else I should do is use GIO to connect to an FTP in an
application that runs as a service, I'm afraid I'll have the same
problem. Do it with CRON or as a service if I'm going to run as root I
will have the same message.
Any suggestions?
Mis proyectos de software libre en:
Github - edwinspire
2017-08-18 10:08 GMT-05:00 Al Thomas <astavale yahoo co uk>:
On Friday, August 18, 2017, 3:21:39 PM GMT+1, Edwin De La Cruz
<edwinspire gmail com> wrote:
// Move file to trash
renamed.trash ();
When I compile and execute it works great, but when I run it with cron
it does not work. I have noticed that when I run the application as
ROOT it does not work and it returns "Operation not supported".
Trash sounds more like a desktop concept. "Not all file systems support
trashing, so this call can return the G_IO_ERROR_NOT_SUPPORTED error." from:
https://developer.gnome.org/gio/stable/GFile.html#g-file-trash
You need to track down the part of your code where the operation is not
supported and re-write you code
from there.
Although really it's better not to run your cron tasks as root. You can
specify the user to run the job in
crontab.
Al
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]