1 /*
2  * h_rmd.c
3  *
4  * (C)1998-2011 by Marc Huber <Marc.Huber@web.de>
5  * All rights reserved.
6  *
7  * $Id: h_rmd.c,v 1.10 2015/03/14 06:11:26 marc Exp marc $
8  *
9  */
10 
11 #include "headers.h"
12 
13 static const char rcsid[] __attribute__ ((used)) = "$Id: h_rmd.c,v 1.10 2015/03/14 06:11:26 marc Exp marc $";
14 
h_rmd(struct context * ctx,char * arg)15 void h_rmd(struct context *ctx, char *arg)
16 {
17     char *t;
18     struct stat st;
19 
20     DebugIn(DEBUG_COMMAND);
21 
22     if ((t = buildpath(ctx, arg)) && (strlen(t) > ctx->rootlen) && !pickystat(ctx, &st, t) && S_ISDIR(st.st_mode) && !rmdir(t))
23 	reply(ctx, MSG_250_Directory_removed);
24     else
25 	reply(ctx, MSG_550_Permission_denied);
26 
27     DebugOut(DEBUG_COMMAND);
28 }
29