From 0387e48ba6882e0997e7a7cb0762d7fec8f9be7a Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Sun, 3 Oct 1999 15:38:38 +0000 Subject: [PATCH] make it possible to set the command protection level with `prot' git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7076 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/security.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/appl/ftp/ftp/security.c b/appl/ftp/ftp/security.c index f81c1b086..b17bdaa13 100644 --- a/appl/ftp/ftp/security.c +++ b/appl/ftp/ftp/security.c @@ -608,25 +608,17 @@ sec_prot(int argc, char **argv) { int level = -1; - if(argc != 2){ - printf("usage: %s (clear | safe | confidential | private)\n", - argv[0]); - code = -1; - return; - } - if(!sec_complete){ + if(argc < 2 || argc > 3) + goto usage; + if(!sec_complete) { printf("No security data exchange has taken place.\n"); code = -1; return; } - level = name_to_level(argv[1]); + level = name_to_level(argv[argc - 1]); - if(level == -1){ - printf("usage: %s (clear | safe | confidential | private)\n", - argv[0]); - code = -1; - return; - } + if(level == -1) + goto usage; if((*mech->check_prot)(app_data, level)) { printf("%s does not implement %s protection.\n", @@ -635,11 +627,22 @@ sec_prot(int argc, char **argv) return; } - if(sec_prot_internal(level) < 0){ - code = -1; - return; - } + if(argc == 2 || strcasecmp(argv[1], "data") == 0) { + if(sec_prot_internal(level) < 0){ + code = -1; + return; + } + } else if(strcasecmp(argv[1], "command") == 0) + command_prot = level; + else + goto usage; code = 0; + return; + usage: + printf("usage: %s (command | data) " + "(clear | safe | confidential | private)\n", + argv[0]); + code = -1; } static enum protection_level request_data_prot;