UserScripts

Tomas Cernik tcernik na oschatz.cz
Pátek Září 21 14:27:02 CEST 2001


Sunday, September 16, 2001, 6:31:04 PM, you wrote:


> Vzdy ked nieco zahlasi "No such", postvem na to strace a ono uz vyklopi o
> co sa to pokusa :-)

strace mi vyklopi toto:

execve("/root/bin/crypt", ["crypt"], [/* 24 vars */]) = 0
strace: exec: No such file or directory


Prikladam jeste zdrojovy text toho scriptu, ktery se mi ale nedari
zkompilovat. Vypadava mi to na tom cteni ze vstupu "cin" a zapisu na
vystup "cout".
Nemuze najit jejich definici a me se ji bohuzel najit taky nepovedlo.
Nevite nekdo v jaky by to melo byt knihovne?
Kompiluji s gcc a parametrem -lcrypt, jinak to vypadava i na volani ty
fce crypt.
Mam RH 7.1.

--- begin of file ---

#include <unistd.h>
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
#include <crypt.h>

void main () {
    timeval time;    
    long seed;  // start value for the random number generator
    unsigned char *salt = (unsigned char*) malloc (3);
    char* in = (char*) malloc (20); // allocate space for input
    char* out= (char*) malloc (20); // allocate space for output
    gettimeofday(&time,NULL);
    seed=time.tv_usec; // get the msec of the current time
    while (seed>255) {seed=seed-253;}
    srand(seed); // initialize the random number generator
    salt[0]=rand(); while (salt[0]>64) {salt[0]/=2;}; salt[0]+=64;
    salt[1]=rand(); while (salt[1]>64) {salt[1]/=2;}; salt[1]+=64;
    salt[2]=0;
    
    cin >> in; // read STDIN
    out = crypt (in, (char*)salt); // encrypt the password
    cout << out; // write encrypted password to STDOUT
};

--- end of file ---

Dekuji za jakoukoli pomoc.

Tomas Cernik




Další informace o konferenci Linux