dbus-marshal-byteswap: Byte-swap Unix fd indexes if needed
[platform/upstream/dbus.git] / CONTRIBUTING.md
1 # Contributing to dbus
2
3 The guidelines in this file are the ideals; it's better to send a
4 not-fully-following-guidelines patch than no patch at all, though.  We
5 can always polish it up.
6
7 ## Source code and issue tracking
8
9 Source code and issue tracking for the D-Bus specification and its
10 reference implementation 'dbus' are provided by freedesktop.org Gitlab:
11 <https://gitlab.freedesktop.org/dbus/dbus>.
12
13 ## Reporting security vulnerabilities
14
15 If you find a security vulnerability that is not known to the public,
16 please report it privately to dbus-security@lists.freedesktop.org
17 or by reporting a Gitlab issue at
18 https://gitlab.freedesktop.org/dbus/dbus/issues/new and marking it
19 as "confidential".
20
21 ## Mailing list
22
23 The D-Bus mailing list is dbus@lists.freedesktop.org; discussion of
24 protocol enhancements, new implementations, etc. should go there.
25
26 ## Code of Conduct
27
28 As a freedesktop.org project, dbus follows the Contributor Covenant,
29 found at: https://www.freedesktop.org/wiki/CodeOfConduct
30
31 Please conduct yourself in a respectful and civilised manner when
32 interacting with community members on mailing lists, IRC, or bug
33 trackers. The community represents the project as a whole, and abusive
34 or bullying behaviour is not tolerated by the project.
35
36 ## Development
37
38 D-Bus uses Git as its version control system. The main repository is
39 hosted on freedesktop.org Gitlab. To clone D-Bus, execute one of the
40 following commands:
41
42     git clone https://gitlab.freedesktop.org/dbus/dbus.git
43     git clone git@gitlab.freedesktop.org:dbus/dbus.git
44
45 The second form is the one that allows pushing, but it also requires
46 an SSH account on the server. The first form allows anonymous
47 checkouts.
48
49 ### Branches
50
51 D-Bus development happens in multiple branches in parallel. The main
52 branches are the current stable branch, with an even minor number (like
53 1.0, 1.2 and 1.4), and the next development branch, with the next odd
54 number. At the time of writing, the stable branch is dbus 1.12.x and
55 the development branch is dbus 1.13.x, leading to a new 1.14.x stable
56 branch in future.
57
58 Stable branches are named after the version number itself (`dbus-1.2`,
59 `dbus-1.4`), whereas the development branch is simply known as
60 `master`.
61
62 New features, enhancements, minor bug fixes, and bug fixes that are
63 unusually intrusive should always be based on the `master` branch.
64
65 Fixes for significant bugs should be developed on the `master` branch
66 and cherry-picked to the most recent stable branch.
67
68 Depending on the release cycles of various Linux distributions, some
69 older stable branches might continue to receive fixes for security
70 vulnerabilities (and sometimes major non-security bugs) for a time.
71 These are announced on the D-Bus mailing list.
72
73 Old development branches are not supported at all, and will not receive
74 any bug fixes - not even for security vulnerabilities. Please do not
75 use a development branch like 1.13.x in your OS distribution, unless
76 you can guarantee that you will upgrade to the next stable branch such
77 as 1.14.x when it becomes available.
78
79 ### Commits
80
81 If you are making changes that you wish to be incorporated upstream,
82 please do as small commits to your local git tree that are individually
83 correct, so there is a good history of your changes.
84
85 The first line of the commit message should be a single sentence that
86 describes the change, optionally with a prefix that identifies the
87 area of the code that is affected.
88
89 The body of the commit message should describe what the patch changes
90 and why, and also note any particular side effects. This shouldn't be
91 empty on most of the cases. It shouldn't take a lot of effort to write a
92 commit message for an obvious change, so an empty commit message body is
93 only acceptable if the questions "What?" and "Why?" are already answered
94 on the one-line summary.
95
96 The lines of the commit message should have at most 76 characters,
97 to cope with the way git log presents them.
98
99 See [notes on commit messages](https://who-t.blogspot.com/2009/12/on-commit-messages.html),
100 [A Note About Git Commit Messages](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
101 or [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/)
102 for recommended reading on writing high-quality commit messages.
103
104 Your patches should also include a Signed-off-by line with your name and
105 email address, indicating that your contribution follows the [Developer's
106 Certificate of Origin](https://developercertificate.org/). If you're
107 not the patch's original author, you should also gather S-o-b's by
108 them (and/or whomever gave the patch to you.) The significance of this
109 is that it certifies that you created the patch, that it was created
110 under an appropriate open source license, or provided to you under those
111 terms. This lets us indicate a chain of responsibility for the copyright
112 status of the code.
113
114 We won't reject patches that lack S-o-b, but it is strongly recommended.
115
116 ### Sending a merge request
117
118 When you consider your changes to be ready for merging to mainline:
119
120 * create a personal fork of <https://gitlab.freedesktop.org/dbus/dbus>
121   on freedesktop.org Gitlab
122 * push your changes to your personal fork as a branch
123 * create a merge request at
124   <https://gitlab.freedesktop.org/dbus/dbus/merge_requests>
125
126 ### Security guidelines
127
128 Most of D-Bus is security sensitive.  Guidelines related to that:
129
130  - avoid `memcpy()`, `sprintf()`, `strlen()`, `snprintf()`, `strlcat()`,
131    `strstr()`, `strtok()`, or any of this stuff. Use `DBusString`.
132    If `DBusString` doesn't have the feature you need, add it
133    to `DBusString`.
134
135    There are some exceptions, for example
136    if your strings are just used to index a hash table
137    and you don't do any parsing/modification of them, perhaps
138    `DBusString` is wasteful and wouldn't help much. But definitely
139    if you're doing any parsing, reallocation, etc. use `DBusString`.
140
141  - do not include system headers outside of `dbus-memory.c`,
142    `dbus-sysdeps.c`, and other places where they are already
143    included. This gives us one place to audit all external
144    dependencies on features in libc, etc.
145
146  - do not use libc features that are "complicated"
147    and may contain security holes. For example, you probably shouldn't
148    try to use `regcomp()` to compile an untrusted regular expression.
149    Regular expressions are just too complicated, and there are many
150    different libc implementations out there.
151
152  - we need to design the message bus daemon (and any similar features)
153    to use limited privileges, run in a chroot jail, and so on.
154
155 http://vsftpd.beasts.org/ has other good security suggestions.
156
157 ### Coding Style
158
159  - Please follow the coding style and indentation of nearby code.
160
161  - C code uses GNU coding conventions (approximately "gnu" style in
162    Emacs), with GLib-like extensions (e.g. lining up function arguments).
163
164  - Write docs for all non-static functions and structs and so on. try
165    `doxygen Doxyfile` prior to commit and try not to cause any new
166    warnings.
167
168  - All external interfaces (network protocols, file formats, etc.)
169    should have documented specifications sufficient to allow an
170    alternative implementation to be written. Our implementation should
171    be strict about specification compliance (should not for example
172    heuristically parse a file and accept not-well-formed
173    data). Avoiding heuristics is also important for security reasons;
174    if it looks funny, ignore it (or exit, or disconnect).
175
176 ### Licensing
177
178 Please match the existing licensing (a dual-license: AFL-2.1 or GPL-2+,
179 recipient's choice). Entirely new modules can be placed under a more
180 permissive license: to avoid license proliferation, our preferred
181 permissive license is the variant of the MIT/X11 license used by the
182 Expat XML library (for example see the top of tools/ci-build.sh).
183
184 ### Build systems
185
186 The primary build system for dbus uses the GNU Autotools suite (Autoconf,
187 Automake and Libtool). This build system is strongly recommended for
188 Unix OS integrators. It can also be used to compile dbus for Windows
189 using the mingw-w64 compiler suite, either by cross-compiling on a Unix
190 system or by using an environment like MSYS2 on Windows.
191
192 There is also a CMake build system. This is primarily there to make it
193 easier to build dbus on Windows, using either a MSYS2/mingw environment
194 or the MSVC compiler from Microsoft Visual Studio. It can also be used
195 on a GNU/Linux system, but this is not recommended for OS integrators.
196
197 Changes contributed to dbus must not break the build for either of these
198 build systems. It is OK for the CMake build system to support fewer
199 options, support fewer operating systems, have less test coverage or
200 build fewer non-essential programs, but it must continue to work on at
201 least GNU/Linux and Windows.
202
203 ### Environment variables
204
205 These are some of the environment variables that are used by the D-Bus
206 client library.
207
208 * `DBUS_VERBOSE=1`
209
210   Turns on printing verbose messages. This only works if D-Bus has been
211   compiled with `--enable-verbose-mode`.
212
213 * `DBUS_MALLOC_FAIL_NTH=n`
214
215   Can be set to a number, causing every *n*th call to `dbus_alloc` or
216   `dbus_realloc` to fail. This only works if D-Bus has been compiled with
217   `--enable-embedded-tests`.
218
219 * `DBUS_MALLOC_FAIL_GREATER_THAN=n`
220
221   Can be set to a number, causing every call to `dbus_alloc` or
222   `dbus_realloc` to fail if the number of bytes to be allocated is greater
223   than the specified number. This only works if D-Bus has been compiled with
224   `--enable-embedded-tests`.
225
226 * `DBUS_TEST_MALLOC_FAILURES=n`
227
228   Many of the D-Bus tests will run over and over, once for each `malloc`
229   involved in the test. Each run will fail a different `malloc`, plus some
230   number of `malloc`s following that malloc (because a fair number of bugs
231   only happen if two or more `malloc`s fail in a row, e.g. error recovery
232   that itself involves `malloc`).  This environment variable sets the
233   number of consecutive `malloc`s to fail.
234
235   Here's why you care: If set to 0, then the `malloc` checking is skipped,
236   which makes the test suite a lot faster. Just run with this
237   environment variable unset before you commit.
238
239 ### Tests
240
241 Please try to write test coverage for all new functionality.
242 We have two broad categories of tests.
243
244 The *modular tests* are enabled by configuring with
245 `--enable-modular-tests`. These mostly use GLib's GTest framework,
246 and are standalone programs that do not affect the contents of the
247 production dbus library and programs. Most of them can be installed
248 alongside the library and programs by configuring with
249 `--enable-installed-tests`.
250
251 The *embedded tests* are enabled by configuring with
252 `--enable-embedded-tests`. Unlike the modular tests, enabling the
253 embedded tests adds special code to libdbus and dbus-daemon, some of
254 which may harm performance or security. A production version of dbus
255 that will be included in an operating system should never have the
256 embedded tests enabled.
257
258 If possible, new test coverage should be provided via modular tests,
259 preferably using GLib's GTest framework. `test/dbus-daemon.c` is a good
260 example.
261
262 ## Information for maintainers
263
264 This section is not directly relevant to infrequent contributors.
265
266 ### Releasing
267
268 To make a release of D-Bus, do the following:
269
270  - check out a fresh copy from Git
271
272  - verify that the libtool versioning/library soname is
273    changed if it needs to be, or not changed if not
274
275  - update the file NEWS based on the git history
276
277  - verify that the version number of dbus-specification.xml is
278    changed if it needs to be; if changes have been made, update the
279    release date in that file
280
281  - update the AUTHORS file with "make update-authors" if necessary
282
283  - the version number should have major.minor.micro, even
284    if micro is 0, i.e. "1.0.0" and "1.2.0" not "1.0"/"1.2"; the micro
285    version should be even for releases, and odd for intermediate snapshots
286
287  - "make distcheck" (DO NOT just "make dist" - pass the check!)
288
289  - if make distcheck fails, fix it.
290
291  - once distcheck succeeds, "git commit -a".  This is the version
292    of the tree that corresponds exactly to the released tarball.
293
294  - tag the tree with "git tag -s -m 'Released X.Y.Z' dbus-X.Y.Z"
295    where X.Y.Z is the version of the release.  If you can't sign
296    then simply created an unsigned annotated tag:
297    "git tag -a -m 'Released X.Y.Z' dbus-X.Y.Z".
298
299  - bump the version number up in configure.ac (so the micro version is odd),
300    and commit it.  Make sure you do this *after* tagging the previous
301    release! The idea is that git has a newer version number
302    than anything released. Similarly, bump the version number of
303    dbus-specification.xml and set the release date to "(not finalized)".
304
305  - merge the branch you've released to the chronologically-later
306    branch (usually "master"). You'll probably have to fix a merge
307    conflict in configure.ac (the version number).
308
309  - push your changes and the tag to the central repository with
310      git push origin master dbus-X.Y dbus-X.Y.Z
311
312  - scp your tarball to freedesktop.org server and copy it to
313    dbus.freedesktop.org:/srv/dbus.freedesktop.org/www/releases/dbus/dbus-X.Y.Z.tar.gz.
314    This should be possible if you're in group "dbus"
315
316  - Update the online documentation with `make -C doc maintainer-upload-docs`.
317
318  - update the wiki page http://www.freedesktop.org/Software/dbus by
319    adding the new release under the Download heading. Then, cut the
320    link and changelog for the previous that was there.
321
322  - post to dbus@lists.freedesktop.org announcing the release.
323
324 ### Making a ".0" stable release
325
326 We create a branch for each stable release. The branch name should be
327 dbus-X.Y which is a branch that has releases versioned X.Y.Z;
328 changes on a stable branch should be limited to significant bug fixes.
329
330 Because we won't make minor changes like keeping up with the latest
331 deprecations on a stable branch, stable branches should turn off the
332 gcc warning for deprecated declarations (e.g. see commit 4ebb275ab7).
333
334 Be extra-careful not to merge master (or any branch based on master) into a
335 stable branch.
336
337 To branch:
338
339     git branch dbus-X.Y
340
341 and upload the branch tag to the server:
342
343     git push origin dbus-X.Y
344
345 To develop in this branch:
346
347     git checkout dbus-X.Y
348
349 ### Code reviews
350
351 The commit rules are approximately these:
352
353  - Fixes that don't affect API or protocol can be committed
354    if any one qualified reviewer other than patch author
355    reviews and approves
356
357  - For fixes that do affect API or protocol, two people
358    in the reviewer group have to review and approve the commit.
359
360  - If there's a live unresolved controversy about a change,
361    don't commit it while the argument is still raging.
362
363  - At their discretion, members of the reviewer group may also commit
364    branches/patches under these conditions:
365
366    - the branch does not add or change API, ABI or wire-protocol
367
368    - the branch solves a known problem and is covered by the regression tests
369
370    - there are no objections from the rest of the review group within
371      a week of the merge request being opened
372
373    - the committer gets a positive review on the merge request from someone
374      they consider qualified to review the change (e.g. a colleague with D-Bus
375      experience; not necessarily a member of the reviewer group)
376
377  - Regardless of reviews, to commit a patch:
378
379     - `make check` must pass
380     - the test suite must be extended to cover the new code
381       as much as reasonably feasible (see Tests above)
382     - the patch has to follow the portability, security, and
383       style guidelines
384     - the patch should as much as reasonable do one thing,
385       not many unrelated changes
386
387    No reviewer should approve a patch without these attributes, and
388    failure on these points is grounds for reverting the patch.
389
390 The reviewer group that can approve patches consists of the members
391 of <https://gitlab.freedesktop.org/dbus/dbus/project_members> with
392 "Maintainer" or "Owner" status.