Add FIND site command.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@791 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1996-09-29 01:27:21 +00:00
parent 744d43f098
commit 5387b76026
2 changed files with 63 additions and 16 deletions

View File

@@ -138,7 +138,7 @@ static int yylex (void);
AUTH ADAT PROT PBSZ CCC MIC
CONF ENC
KAUTH KLIST
KAUTH KLIST FIND
LEXERR
@@ -521,27 +521,38 @@ cmd
}
}
| SITE SP KAUTH SP STRING CRLF
| SITE SP KAUTH check_login SP STRING CRLF
{
char *p;
size_t s;
p = strpbrk($5, " \t");
if(p){
if($4 && $6 != NULL){
p = strpbrk($6, " \t");
if(p){
*p++ = 0;
s = strspn(p, " \t");
if(s >= 0)
kauth($5, p + s);
kauth($6, p + s);
else
kauth($5, p);
}else
kauth($5, NULL);
free($5);
kauth($6, p);
}else
kauth($6, NULL);
}
if($6 != NULL)
free($6);
}
| SITE SP KLIST CRLF
| SITE SP KLIST check_login CRLF
{
if($4)
klist();
}
| SITE SP FIND check_login SP STRING CRLF
{
if($4 && $6 != NULL)
find($6);
if($6 != NULL)
free($6);
}
| STOU check_login SP pathname CRLF
{
if ($2 && $4 != NULL)
@@ -911,6 +922,8 @@ struct tab sitetab[] = {
{ "KAUTH", KAUTH, STR1, 1, "<sp> principal [ <sp> ticket ]" },
{ "KLIST", KLIST, ARGS, 1, "(show ticket file)" },
{ "FIND", FIND, STR1, 1, "<sp> globexpr" },
{ NULL, 0, 0, 0, 0 }
};

View File

@@ -804,7 +804,7 @@ retrieve(char *cmd, char *name)
}
}
if(p->ext){
fin = ftpd_popen(line, "r", 0);
fin = ftpd_popen(line, "r", 0, 0);
closefunc = ftpd_pclose;
st.st_size = -1;
#ifdef HAVE_ST_BLKSIZE
@@ -815,7 +815,7 @@ retrieve(char *cmd, char *name)
}
} else {
sprintf(line, cmd, name), name = line;
fin = ftpd_popen(line, "r", 1);
fin = ftpd_popen(line, "r", 1, 0);
closefunc = ftpd_pclose;
st.st_size = -1;
#ifdef HAVE_ST_BLKSIZE
@@ -1291,8 +1291,8 @@ statfilecmd(char *filename)
int c;
char line[LINE_MAX];
sprintf(line, "/bin/ls -lA %s", filename);
fin = ftpd_popen(line, "r", 1);
sprintf(line, "/bin/ls -la %s", filename);
fin = ftpd_popen(line, "r", 1, 0);
lreply(211, "status of %s:", filename);
while ((c = getc(fin)) != EOF) {
if (c == '\n') {
@@ -1386,8 +1386,10 @@ int_reply(int n, char *c, const char *fmt, va_list ap)
char buf[10240];
char *p;
p=buf;
sprintf(p, "%d%s", n, c);
p+=strlen(p);
if(n){
sprintf(p, "%d%s", n, c);
p+=strlen(p);
}
vsprintf(p, fmt, ap);
p+=strlen(p);
sprintf(p, "\r\n");
@@ -1417,6 +1419,15 @@ lreply(int n, const char *fmt, ...)
va_end(ap);
}
void
nreply(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
int_reply(0, NULL, fmt, ap);
va_end(ap);
}
static void
ack(char *s)
{
@@ -1861,3 +1872,26 @@ out:
globfree(&gl);
}
}
int
find(char *pattern)
{
char line[1024];
FILE *f;
sprintf(line, "/bin/locate -d /etc/locatedb %s", pattern);
f = ftpd_popen(line, "r", 1, 1);
if(f == NULL){
perror_reply(550, "/bin/locate");
return 1;
}
lreply(200, "Output from find.");
while(fgets(line, sizeof(line), f)){
if(line[strlen(line)-1] == '\n')
line[strlen(line)-1] = 0;
nreply("%s", line);
}
reply(200, "Done");
ftpd_pclose(f);
return 0;
}