Jump to content

is there a *.* just like in Windows?


egzozcu

Recommended Posts

Hello there,

Like the title says. is there a thing that does the same job like in Windows?

I have a folder that contains a file with .log extention and another one with .leases extention.

And I have this command line: exec('openssl ts -verify -data /tmp/' . $log_type . '.log -in /tmp/' . $log_type . '.l*.der -token_in -CAfile /CA/cacert.pem -untrusted /CA/tsacert.pem', $result);

when I run the above command line it starts varification process only on the file that has .log extention. And if I change the bold marked .log in the above command line with .leases then re run the command line then it start the same varification process but this time only on the file that has .leases extention.

What I want here is that whenever I run the command line it detects both the files in the folder and start the verification process, no matter it is .log or .leases extention.

So what is the thing I should write in the place of the bold marked .log to make it detect any extention? I have tried *.* or '.' or * or .l* but non of these worked 

Any help would be much appreciated.

Thanks in advance.

Link to comment
Share on other sites

Either .*, .l* would work to match your .log and .lease files.  The command you're executing has to be capable of processing multiple files though and as far as I can see reading the man page for openssl ts it doesn't seem like it can.

Quote

-data file_to_hash
           The response or token must be verified against file_to_hash. The file is hashed with the message digest algorithm specified in the token.  The -digest and -queryfile options must not be specified with this one.
           (Optional)

Note it says file_to_hash, singular.

So you'd need to find your .log and .lease files yourself, then run that command for each one individually.

Link to comment
Share on other sites

16 hours ago, kicken said:

Either .*, .l* would work to match your .log and .lease files.  The command you're executing has to be capable of processing multiple files though and as far as I can see reading the man page for openssl ts it doesn't seem like it can.

Note it says file_to_hash, singular.

So you'd need to find your .log and .lease files yourself, then run that command for each one individually.

this is the complete script :

<?php

$file = $_POST['file'];
$exploded = explode('.', basename($file));
$log_type = $exploded[0];

chdir('/tmp');
exec('cp /var/imzali_kayitlar/' . $file . ' ./');
exec('tar zxvf ' . basename($file));
// Doğrulama komutu
exec('openssl ts -verify -data /tmp/' . $log_type . '.log -in /tmp/' . $log_type . '.log.der -token_in -CAfile /CA/cacert.pem -untrusted /CA/tsacert.pem', $result);

if ($result[0] == 'Verification: OK') {
    $imza = file_get_contents($log_type . '.log.imza');
    echo '<p class="success">Doğrulama başarılı!</p>';
    echo '<div>' . nl2br($imza) . '</div>';
}
else {
    echo '<p class="error">Doğrulama başarısız!</p>';
}

exec('rm ' . $log_type . '.l*');
exit;

 

I have the .log and .leases files inside a folder, and to run the script I have a webpage that I go there where there is a button beside every file then I click on the button then it runs the above script in the backgroud and shows the result if the verification is ok or not.

here is some pics of the files and the webpage:

image.png

 

image.thumb.png.6a58e5637a06d6c26282e447664e2f81.png

 

 

image.thumb.png.fd2859ae4f39c07c784591332213ae8d.png

 

when I change .log to .leases then the above will be opposite.

.* or .l* doesnt work.

 

Edited by egzozcu
Link to comment
Share on other sites

Quote

And here it gave failed because the .log is written in the script

Don't hard-code the .log then.  You have access to the full file name including the extension in your script.  You use it to generate your $log_type variable.  The extension you need can similarly be extracted and used in the script rather than a hard-coded value.  You have:

$file = $_POST['file'];
$exploded = explode('.', basename($file));
$log_type = $exploded[0];

I'm assuming that $_POST['file'] is the full name shown in the image, ie dhcpd.leases.20220708-030000.tar.gz.  Given that, then when you explode it on the dots, you get an array with the different components.  You're taking $exploded[0] which is the first part (dhcpd).  $exploded[1] would be the second part, the extension you want (leases).  Use them both to assemble your command later.

$file = $_POST['file'];
$exploded = explode('.', basename($file));
$log_type = $exploded[0];
$log_extension = $exploded[1];

//...

exec('openssl ts -verify -data /tmp/' . $log_type . '.' . $log_extension . ' -in /tmp/' . $log_type . '.' . $log_extension . '.der -token_in -CAfile /CA/cacert.pem -untrusted /CA/tsacert.pem', $result);

 

Edited by kicken
  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.