Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Discussion forum about ELOG  Not logged in ELOG logo
icon5.gif   Using curl to post new entries, posted by Florian Feldbauer on Wed Sep 2 10:24:58 2020 
    icon2.gif   Re: Using curl to post new entries, posted by Florian Feldbauer on Wed Sep 2 11:56:04 2020 
       icon2.gif   Re: Using curl to post new entries, posted by Stefan Ritt on Wed Sep 2 15:42:40 2020 
Message ID: 69211     Entry time: Wed Sep 2 15:42:40 2020     In reply to: 69210
Icon: Reply  Author: Stefan Ritt  Author Email: stefan.ritt@psi.ch 
Category: Question  OS: Linux  ELOG Version: 3.1.3 
Subject: Re: Using curl to post new entries 

This is correct. The elogd daemon needs username and password in parameters "unm" and "upwd". The password must be SHA256 encoded, so best is to grab it from the password file. This way one does not have to send clear text passwords over the network.

Florian Feldbauer wrote:

After going through the code of the Python API (https://github.com/paulscherrerinstitute/py_elog/blob/master/elog/logbook.py) I tried the following:
$ python3
>>> from passlib.hash import sha256_crypt
>>> sha256_crypt.hash( 'foobaa', salt='', rounds=5000)[4:]
'waa2sT6eBt.qk0wsucX/nxU5GcqffqlEx6ja5Lg1OR5'
>>> from datetime import datetime
>>> datetime.now().timestamp()
1599039390.964989
$ curl -F cmd=Submit -F exp=labor -F unm=florian -F upwd='waa2sT6eBt.qk0wsucX/nxU5GcqffqlEx6ja5Lg1OR5' -F Encoding=plain -F When=1599039390.964989 -F Author=curl -F Subject="curl test" -F Category=General -F Type=Diary -F Text="foo baa" http://localhost:8080/test/

This worked. It seems to me, that the "-u" option from Curl is not working for elog.

Cheers,
Florian

 

Florian Feldbauer wrote:

Hey,

i'm trying to use curl to post new entries to our logbook as described here: https://elog.psi.ch/elogs/Forum/68597.
The Elog is installed via the Deban package on Buster.
I created a test logbook with attributes Author, Type, Category and Subject.

curl -u florian:foobaa -F cmd=Submit -F Author=Florian -F Type=Diary -F Category=General -F Subject="testing curl" -F Text="foo baa" http://localhost:8080/test
<!DOCTYPE html>
<html><head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<title>ELOG Login</title>
<link rel="stylesheet" type="text/css" href="elog.css">
<link rel="shortcut icon" href="favicon.ico" />
<link rel="icon" href="favicon.png" type="image/png" />
</head>
<body OnLoad="document.form1.uname.focus();">
<form name=form1 method="POST" action="./" enctype="multipart/form-data">

<input type=hidden name=redir value="">
<table class="login_frame" cellspacing=0 align=center><tr><td class="login_title">Please login</td></tr>
<tr><td class="login_form">
<span class="overlay_wrapper">
<label for="uname" id="uname" class="overlabel">Username</label>
<input type="text" class="login_input" name="uname" value="" title="Username" onInput="document.getElementById('uname').style.display='none';">
</span></td></tr>
<tr><td class="login_form">
<span class="overlay_wrapper">
<label for="upassword" id="upassword" class="overlabel">Password</label>
<input type="password" class="login_input" name="upassword" onInput="document.getElementById('upassword').style.display='none';">
</span></td></tr>
<tr><td align=center class="login_form"><input type=checkbox checked name=remember value=1>
Keep me logged in on this computer
for the next 31 days or until I log out</td></tr>
<tr><td align=center class="login_form">
<a href="?cmd=Forgot">Forgot password?</a></td></tr>
<tr><td align=center class="login_form_bottom"><input type="submit" class="login_submit" value="Submit"></td></tr></table>
<center><a class="bottomlink" title="Goto ELOG home page" href="https://midas.psi.ch/elog/">ELOG V3.1.3-7933898</a></center></form></body></html>

 

As you can see, curl only prints the login page of the logbook and no new entry has been created. Any suggestions what might go worng here?

Regards,
Florian

 

 

ELOG V3.1.5-2eba886