~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to lib/util/util.h

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#ifndef _SAMBA_UTIL_H_
22
22
#define _SAMBA_UTIL_H_
23
23
 
24
 
#if _SAMBA_BUILD_ == 4
25
 
#include "../lib/util/charset/charset.h"
26
 
#endif
27
 
#include "../lib/util/attr.h"
 
24
#include "lib/util/charset/charset.h"
 
25
#include "lib/util/attr.h"
28
26
 
29
27
/* for TALLOC_CTX */
30
28
#include <talloc.h>
39
37
extern const char *logfile;
40
38
extern const char *panic_action;
41
39
 
42
 
#include "../lib/util/time.h"
43
 
#include "../lib/util/data_blob.h"
44
 
#include "../lib/util/xfile.h"
45
 
#include "../lib/util/mutex.h"
46
 
#include "../lib/util/byteorder.h"
47
 
#include "../lib/util/talloc_stack.h"
 
40
#include "lib/util/time.h"
 
41
#include "lib/util/data_blob.h"
 
42
#include "lib/util/xfile.h"
 
43
#include "lib/util/byteorder.h"
 
44
#include "lib/util/talloc_stack.h"
48
45
 
49
46
/**
50
47
 * assert macros 
60
57
            __FILE__, __LINE__, #b)); }} while (0)
61
58
#endif
62
59
 
63
 
#if _SAMBA_BUILD_ == 4
64
 
#ifdef VALGRIND
65
 
#define strlen(x) valgrind_strlen(x)
66
 
size_t valgrind_strlen(const char *s);
67
 
#endif
68
 
#endif
69
 
 
70
60
#ifndef ABS
71
61
#define ABS(a) ((a)>0?(a):(-(a)))
72
62
#endif
73
63
 
74
 
#include "../lib/util/memory.h"
 
64
#include "lib/util/memory.h"
75
65
 
76
66
/**
77
67
 * Write backtrace to debug log
88
78
setup our fault handlers
89
79
**/
90
80
_PUBLIC_ void fault_setup(const char *pname);
 
81
_PUBLIC_ void fault_setup_disable(void);
91
82
#endif
92
83
 
93
84
/**
142
133
 **/
143
134
_PUBLIC_ pid_t sys_getpid(void);
144
135
 
 
136
_PUBLIC_ int sys_getpeereid( int s, uid_t *uid);
 
137
 
 
138
struct sockaddr;
 
139
 
 
140
_PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa,
 
141
                             int salen,
 
142
                             char *host,
 
143
                             size_t hostlen,
 
144
                             char *service,
 
145
                             size_t servlen,
 
146
                             int flags);
 
147
_PUBLIC_ int sys_connect(int fd, const struct sockaddr * addr);
 
148
 
145
149
/* The following definitions come from lib/util/genrand.c  */
146
 
 
147
150
/**
148
151
 Copy any user given reseed data.
149
152
**/
178
181
_PUBLIC_ bool check_password_quality(const char *s);
179
182
 
180
183
/**
 
184
 * Generate a random text password.
 
185
 */
 
186
_PUBLIC_ char *generate_random_password(TALLOC_CTX *mem_ctx, size_t min, size_t max);
 
187
 
 
188
/**
181
189
 Use the random number generator to generate a random string.
182
190
**/
183
191
_PUBLIC_ char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list);
450
458
 
451
459
/**
452
460
 * build a null terminated list of strings from an argv-like input string 
453
 
 * Entries are seperated by spaces and can be enclosed by quotes. 
 
461
 * Entries are separated by spaces and can be enclosed by quotes.
454
462
 * Does NOT support escaping
455
463
 */
456
464
_PUBLIC_ char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
458
466
/**
459
467
 * join a list back to one string 
460
468
 */
461
 
_PUBLIC_ char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char seperator);
 
469
_PUBLIC_ char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char separator);
462
470
 
463
471
/** join a list back to one (shell-like) string; entries 
464
 
 * seperated by spaces, using quotes where necessary */
 
472
 * separated by spaces, using quotes where necessary */
465
473
_PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char sep);
466
474
 
467
475
/**
477
485
/**
478
486
   Return true if all the elements of the list match exactly.
479
487
 */
480
 
_PUBLIC_ bool str_list_equal(const char **list1, const char **list2);
 
488
_PUBLIC_ bool str_list_equal(const char * const *list1, const char * const *list2);
481
489
 
482
490
/**
483
491
  add an entry to a string list
535
543
_PUBLIC_ const char **str_list_copy_const(TALLOC_CTX *mem_ctx,
536
544
                                          const char **list);
537
545
 
 
546
/**
 
547
 * Needed for making an "unconst" list "const"
 
548
 */
 
549
_PUBLIC_ const char **const_str_list(char **list);
 
550
 
538
551
 
539
552
/* The following definitions come from lib/util/util_file.c  */
540
553
 
596
609
_PUBLIC_ int fdprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
597
610
_PUBLIC_ bool large_file_support(const char *path);
598
611
 
 
612
/*
 
613
  compare two files, return true if the two files have the same content
 
614
 */
 
615
bool file_compare(const char *path1, const char *path2);
 
616
 
599
617
/* The following definitions come from lib/util/util.c  */
600
618
 
601
619
 
640
658
/**
641
659
 Sleep for a specified number of milliseconds.
642
660
**/
643
 
_PUBLIC_ void msleep(unsigned int t);
 
661
_PUBLIC_ void smb_msleep(unsigned int t);
644
662
 
645
663
/**
646
664
 Get my own name, return in talloc'ed storage.
648
666
_PUBLIC_ char* get_myname(TALLOC_CTX *mem_ctx);
649
667
 
650
668
/**
651
 
 Return true if a string could be a pure IP address.
652
 
**/
653
 
_PUBLIC_ bool is_ipaddress(const char *str);
654
 
 
655
 
/**
656
 
 Interpret an internet address or name into an IP address in 4 byte form.
657
 
**/
658
 
_PUBLIC_ uint32_t interpret_addr(const char *str);
659
 
 
660
 
/**
661
 
 A convenient addition to interpret_addr().
662
 
**/
663
 
_PUBLIC_ struct in_addr interpret_addr2(const char *str);
664
 
 
665
 
/**
666
 
 Check if an IP is the 0.0.0.0.
667
 
**/
668
 
_PUBLIC_ bool is_zero_ip_v4(struct in_addr ip);
669
 
 
670
 
/**
671
 
 Are two IPs on the same subnet?
672
 
**/
673
 
_PUBLIC_ bool same_net_v4(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
674
 
 
675
 
_PUBLIC_ bool is_ipaddress_v4(const char *str);
676
 
 
677
 
/**
678
669
 Check if a process exists. Does this work on all unixes?
679
670
**/
680
671
_PUBLIC_ bool process_exists_by_pid(pid_t pid);
686
677
_PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type);
687
678
 
688
679
/**
 
680
 * Write dump of binary data to a callback
 
681
 */
 
682
void dump_data_cb(const uint8_t *buf, int len,
 
683
                  bool omit_zero_bytes,
 
684
                  void (*cb)(const char *buf, void *private_data),
 
685
                  void *private_data);
 
686
 
 
687
/**
689
688
 * Write dump of binary data to the log file.
690
689
 *
691
690
 * The data is only written if the log level is at least level.
696
695
 * Write dump of binary data to the log file.
697
696
 *
698
697
 * The data is only written if the log level is at least level.
699
 
 * 16 zero bytes in a row are ommited
 
698
 * 16 zero bytes in a row are omitted
700
699
 */
701
700
_PUBLIC_ void dump_data_skip_zeros(int level, const uint8_t *buf, int len);
702
701
 
783
782
int gen_fnmatch(const char *pattern, const char *string);
784
783
#endif
785
784
 
786
 
/* The following definitions come from lib/util/mutex.c  */
787
 
 
788
 
 
789
 
/**
790
 
  register a set of mutex/rwlock handlers. 
791
 
  Should only be called once in the execution of smbd.
792
 
*/
793
 
_PUBLIC_ bool register_mutex_handlers(const char *name, struct mutex_ops *ops);
794
 
 
795
785
/* The following definitions come from lib/util/idtree.c  */
796
786
 
797
787
 
839
829
/**
840
830
 Become a daemon, discarding the controlling terminal.
841
831
**/
842
 
_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group);
 
832
_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout);
843
833
 
844
834
/**
845
835
 * Load a ini-style file.
852
842
bool unmap_file(void *start, size_t size);
853
843
 
854
844
void print_asc(int level, const uint8_t *buf,int len);
 
845
void print_asc_cb(const uint8_t *buf, int len,
 
846
                  void (*cb)(const char *buf, void *private_data),
 
847
                  void *private_data);
855
848
 
856
849
/**
857
850
 * Add an id to an array of ids.
861
854
 */
862
855
 
863
856
bool add_uid_to_array_unique(TALLOC_CTX *mem_ctx, uid_t uid,
864
 
                             uid_t **uids, size_t *num_uids);
 
857
                             uid_t **uids, uint32_t *num_uids);
865
858
bool add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid,
866
 
                             gid_t **gids, size_t *num_gids);
867
 
 
 
859
                             gid_t **gids, uint32_t *num_gids);
 
860
 
 
861
/**
 
862
 * Allocate anonymous shared memory of the given size
 
863
 */
 
864
void *anonymous_shared_allocate(size_t bufsz);
 
865
void anonymous_shared_free(void *ptr);
 
866
 
 
867
/*
 
868
  run a command as a child process, with a timeout.
 
869
 
 
870
  any stdout/stderr from the child will appear in the Samba logs with
 
871
  the specified log levels
 
872
 
 
873
  If callback is set then the callback is called on completion
 
874
  with the return code from the command
 
875
 */
 
876
struct tevent_context;
 
877
struct tevent_req;
 
878
struct tevent_req *samba_runcmd_send(TALLOC_CTX *mem_ctx,
 
879
                                     struct tevent_context *ev,
 
880
                                     struct timeval endtime,
 
881
                                     int stdout_log_level,
 
882
                                     int stderr_log_level,
 
883
                                     const char * const *argv0, ...);
 
884
int samba_runcmd_recv(struct tevent_req *req, int *perrno);
 
885
 
 
886
#ifdef DEVELOPER
 
887
void samba_start_debugger(void);
 
888
#endif
868
889
 
869
890
#endif /* _SAMBA_UTIL_H_ */