File: cancelmsg.c

package info (click to toggle)
courier 1.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,084 kB
  • sloc: ansic: 126,176; cpp: 24,278; sh: 8,957; perl: 4,127; makefile: 3,192; sed: 16
file content (54 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
** Copyright 1998 - 1999 Double Precision, Inc.
** See COPYING for distribution information.
*/

#include	"courier.h"
#include	"comqueuename.h"
#include	"commsgcancel.h"
#include	"comctlfile.h"
#include	"comparseqid.h"
#include	"comctlfile.h"
#include	<sys/types.h>
#include	<sys/uio.h>
#include	<string.h>
#include	<signal.h>
#include	<stdlib.h>
#if	HAVE_UNISTD_H
#include	<unistd.h>
#endif
#if	HAVE_FCNTL_H
#include	<fcntl.h>
#endif
#if	HAVE_SYS_IOCTL_H
#include	<sys/ioctl.h>
#endif
#if	HAVE_SYS_STAT_H
#include	<sys/stat.h>
#endif

/*
**	NOTE - this program must be setuid and setgid to daemon.
**	setuid is required - queue file is read-only by owner.
*/

int main(int argc, char **argv)
{
const	char *qid;

	if (chdir(courierdir()))
	{
		perror("chdir");
		return (1);
	}
	if (argc < 2)	return (0);

	qid=argv[1];
	if (msgcancel(qid, (const char **)argv+2, argc-2, 1))
	{
		fprintf(stderr, "Message not found.\n");
		exit(1);
	}
	printf("Message scheduled for cancellation.\n");
	return (0);
}