[Vala] problem writing to a file that needs root permission



Hello.I'd like to replace the content of the file /etc/sudoers .
In the terminal I can do it using
echo '#attempt' | gksudo tee /etc/sudoers

I've tried this with no success:[Permission denied]

 private void copy_content () {
        try {
                string file_target="/etc/sudoers";
                string file_source =
"/home/one/Desktop/sudoersoriginal.txt";
                var file = File.new_for_path(file_source);
                var thefile_stream = file.copy
(File.new_for_path(file_target), FileCopyFlags.OVERWRITE, null, null);
        } catch (Error e) {
          stderr.printf ("Error: %s\n", e.message);
        }
    }

How should I do it?

Thanks.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]