File: prog.c

package info (click to toggle)
mysecureshell 2.00%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 888 kB
  • sloc: ansic: 7,421; sh: 700; perl: 264; makefile: 116
file content (61 lines) | stat: -rw-r--r-- 1,662 bytes parent folder | download | duplicates (4)
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
55
56
57
58
59
60
61
/*
 MySecureShell permit to add restriction to modified sftp-server
 when using MySecureShell as shell.
 Copyright (C) 2007-2014 MySecureShell Team

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation (version 2)

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#include "../config.h"
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "hash.h"
#include "ip.h"
#include "prog.h"
#include "../SftpServer/SftpWho.h"

int count_program_for_uid(/*@null@*/ const char *login)
{
	t_sftpwho *who;
	int i, nb;

	nb = 0;
	if ((who = SftWhoGetAllStructs()) != NULL)
	{
		for (i = 0; i < SFTPWHO_MAXCLIENT; i++)
			if ((who[i].status & SFTPWHO_STATUS_MASK) != SFTPWHO_EMPTY)
				if (login == NULL || strcmp(who[i].user, login) == 0)
					nb++;
	}
	return (nb);
}

int count_program_for_ip(/*@null@*/ const char *host)
{
	t_sftpwho *who;
	int i, nb;

	nb = 0;
	if ((who = SftWhoGetAllStructs()) != NULL)
	{
		for (i = 0; i < SFTPWHO_MAXCLIENT; i++)
			if ((who[i].status & SFTPWHO_STATUS_MASK) != SFTPWHO_EMPTY)
				if (host == NULL || strcmp(who[i].ip, host) == 0)
					nb++;
	}
	return (nb);
}