Thanks for the response Martin and Stef!

Adding: { superuser: "try" } worked - thanks!  But I was worried about
the "tailing" functionality of watch so I'll now purse the manual
tailing approach :-)

Thanks again,
Mark

On 03/07/2018 10:27 AM, Stef Walter wrote:
> On 07.03.2018 16:05, Mark Reynolds wrote:
>> Hello,
>>
>> So I am running into two issues with file watching on cockpit-151-2
>>
>> [1]  The first one appears to be a permissions issue.  So I am trying to
>> watch a file that the Cockpit user does have immediate permissions to,
>> but the Cockpit user does have sudo rights.  When I try to watch the
>> file, I get an error:  "Not permitted to perform this action." - I'm
>> assuming it's permissions issue because if I watch a file in /tmp it
>> works fine (I also tried disabling selinux but no luck).
>>
>> My code:
>>
>>         var logfile =
>> cockpit.file("/var/log/dirsrv/slapd-localhost/errors");
>>         //var logfile = cockpit.file("/tmp/errors");
>>         errorslog_watch = logfile.watch(function (content, tag, error) {
>>           $('#errorslog-area').text(content);
>>           console.log("We should have logged something: (" + content +
>> ") err: " + error);
>>         });
>>
>> This generates in console:
>>
>>     We should have logged something: (null) err: Not permitted to
>> perform this action.
>>
>> I'm not 100% sure what that errors means, but is there something what
>> will invoke sudo on the file access/watching?
> I think you want something like:
>
> var logfile = cockpit.file("/tmp/errors", { "superuser": true });
>
>> [2]  What I want to do is the equivalent of "tailing" a log file, and I
>> would like to use Cockpit's file watching functionality to do this. 
>> However, when the log file changes the entire file content is returned. 
>> Our log files can grow up to 100mb.  Is there a way to only return the
>> last N lines of a file when it changes without loading the entire
>> content into memory?
> I'd suggest just running the "tail" command:
>
> var proc = cockpit.spawn(["tail", "-f", "/tmp/errors"], { "superuser":
> true });
>
> And then using proc.stream() to get the data.
>
> Hope that helps,
>
> Stef
>
>
>
> _______________________________________________
> cockpit-devel mailing list -- cockpit-devel@lists.fedorahosted.org
> To unsubscribe send an email to cockpit-devel-le...@lists.fedorahosted.org

_______________________________________________
cockpit-devel mailing list -- cockpit-devel@lists.fedorahosted.org
To unsubscribe send an email to cockpit-devel-le...@lists.fedorahosted.org

Reply via email to